systemctl: add support for --wait to is-system-running
authorFilipe Brandenburger <filbranden@google.com>
Sat, 4 Aug 2018 06:10:54 +0000 (23:10 -0700)
committerLennart Poettering <lennart@poettering.net>
Tue, 7 Aug 2018 07:33:25 +0000 (09:33 +0200)
commitadb6cd9be2b7e9e614d2b5835c7b70cf8eacc852
tree38e2d2f41e91ef5ed8e297c187dad5bfde48283d
parent4027f96aa08c73f109aa46b89842ca0e25c9c0e9
systemctl: add support for --wait to is-system-running

This makes it possible to wait until boot is finished without having to poll
for this command repeatedly, instead using the syntax:

  $ systemctl is-system-running --wait

Waiting is implemented by waiting for the StartupFinished signal to be posted
on the bus.

Register the matcher before checking for the property to avoid race conditions.

Tested by artificially delaying startup with a oneshot service and calling this
command, checked that it emitted `running` and exited with a 0 return code as
soon as the delay service completed startup.

Also tested that booting to degraded state unblocks the command.

Inserted a delay between getting the property and waiting for the signal and
confirmed this seems to work free of race conditions.

Updated the --help text (under --wait) and the man page to document the new
feature.
man/systemctl.xml
src/systemctl/systemctl.c