diff options
author | Philipp Brüschweiler <blei42@gmail.com> | 2013-03-10 15:14:01 +0100 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2013-03-19 14:28:23 -0400 |
commit | 7a3ec74cb61c0faae18dfec3782f58b91a193801 (patch) | |
tree | 5aa207a0956d8c7b99d9784e6295b7c99d7a1018 /src/weston-launch.c | |
parent | ff253129c5b7f2f841d50f3e5dce675b2d31464e (diff) | |
download | weston-7a3ec74cb61c0faae18dfec3782f58b91a193801.tar.gz |
weston-launch: return better value if weston dies because of a signal
Before this commit, weston-launch returned 0 if weston was killed by a
signal. This makes it hard to automatically test weston by using
weston-launch, as there is no way to know why weston was terminated.
This commit makes weston-launch return 10+N instead, where N is the code
of the signal that terminated weston. 10 was chosen because it allows a
script to distinguish it from the case that weston-launch itself was
killed by a signal (128+N), and does not overlap the standard exit codes
defined in sysexits.h.
Partial fix for https://bugs.freedesktop.org/show_bug.cgi?id=60935. I
can't reproduce the SIGHUP using the fbdev backend.
v3: better commit message.
Diffstat (limited to 'src/weston-launch.c')
-rw-r--r-- | src/weston-launch.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/weston-launch.c b/src/weston-launch.c index 98f01113..407d1356 100644 --- a/src/weston-launch.c +++ b/src/weston-launch.c @@ -420,7 +420,7 @@ static int handle_signal(struct weston_launch *wl) { struct signalfd_siginfo sig; - int pid, status; + int pid, status, ret; if (read(wl->signalfd, &sig, sizeof sig) != sizeof sig) { error(0, errno, "reading signalfd failed"); @@ -432,7 +432,19 @@ handle_signal(struct weston_launch *wl) pid = waitpid(-1, &status, 0); if (pid == wl->child) { wl->child = 0; - quit(wl, WIFEXITED(status) ? WEXITSTATUS(status) : 0); + if (WIFEXITED(status)) + ret = WEXITSTATUS(status); + else if (WIFSIGNALED(status)) + /* + * If weston dies because of signal N, we + * return 10+N. This is distinct from + * weston-launch dying because of a signal + * (128+N). + */ + ret = 10 + WTERMSIG(status); + else + ret = 0; + quit(wl, ret); } break; case SIGTERM: |