Skip to content

weston-launch: fix signal delivery

Stefan Agner requested to merge agners/weston:fix-weston-launch-ctrl-c into master

This makes sure that Signals get delivered to Weston when using weston-launch.

Before this patch, the process hierarchy looks like this:

 6484 pts/0    S+     0:00 weston-launch --verbose --user=root --tty=/dev/tty7 -- --use-pixman
 6489 tty7     Ss+    0:00  \_ /bin/sh -l -c /usr/local/bin/weston "$@" weston --use-pixman
 6493 tty7     S+     0:00      \_ /usr/local/bin/weston --use-pixman
 6494 tty7     S+     0:00          \_ /usr/local/libexec/weston-keyboard
 6495 tty7     S+     0:00          \_ /usr/local/libexec/weston-desktop-shell

A Ctrl-C to weston-launch would get caught and forwarded (see handle_signal in weston-launch.c). However, the direct child is the shell, which does not do anything with the SIGINT signal.

With this patch the direct child of weston-launch is weston, which then actually handles the signal properly:

 6595 pts/0    S+     0:00 weston-launch --verbose --user=root --tty=/dev/tty7 -- --use-pixman
 6600 tty7     Ss+    0:00  \_ /usr/local/bin/weston --use-pixman
 6604 tty7     S+     0:00      \_ /usr/local/libexec/weston-keyboard
 6605 tty7     S+     0:00      \_ /usr/local/libexec/weston-desktop-shell

This then makes sure that Weston properly get shut down on Ctrl+C:

weston-launch: sending Interrupt to pid 6600
[2019-11-09 00:06:59.083][log] caught signal 2
...
weston-launch: signal Child exited received

Merge request reports