<div dir="ltr"><div><div><div><div><div><div><div>It would be really nice to have an utility that waits until a unit is transitioned from the activating state. My problem is that I wanted to replace in a shell script a sequence like:<br></div><div><br>sudo -u some_user ssh -f port_forwarding host<br></div></div>use_forwarded_ports<br></div>kill hopefully rightly guessed ssh PID<br><br></div>with something like<br><br></div>sudo systemd-run --uid user --service-type=forking ...  ssh -f port_forwarding host<br></div>use_forwarded_ports<br></div><div>sudo systemctl stop unit_name<br><br></div><div>as that is easier to make reliable. However, this does not work as I expected as systemd-run does not wait for the ssh -f unit to transition from the activating state indicating that port forwarding is established. So I need to implement own wait or polling.<br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 31 March 2015 at 05:51, Andrei Borzenkov <span dir="ltr"><<a href="mailto:arvidjaar@gmail.com" target="_blank">arvidjaar@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">В Mon, 30 Mar 2015 09:48:25 +0200<br>
Igor Bukanov <<a href="mailto:igor@mir2.org">igor@mir2.org</a>> пишет:<br>
<div><div class="h5"><br>
> As I understand, the systemd-run utility returns immediately even with<br>
> --service-type=forking. What is the proper way then to wait using a shell<br>
> until the main service process forks the child and exists signaling<br>
> initialization?<br>
<br>
</div></div>It is not limited to forking. systemd-run simply queues request to<br>
start unit, same as systemctl does. It would need to actually wait<br>
until systemd reports that unit is started.<br>
</blockquote></div><br></div>