[PATCH weston 2/2] weston-launch: return correct error code if weston dies because of a signal

Philipp Brüschweiler blei42 at gmail.com
Sat Mar 9 10:38:57 PST 2013


Partial fix for https://bugs.freedesktop.org/show_bug.cgi?id=60935. The
correct code is now returned, but I can't reproduce the SIGHUP using the
fbdev backend.
---
 src/weston-launch.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/weston-launch.c b/src/weston-launch.c
index 98f0111..52082cf 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,18 @@ 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))
+				/*
+				 * This seems to be a widely used convention,
+				 * at least bash handles termination by signal
+				 * like this (see man bash).
+				 */
+				ret = 128 + WTERMSIG(status);
+			else
+				ret = 0;
+			quit(wl, ret);
 		}
 		break;
 	case SIGTERM:
-- 
1.8.1.5



More information about the wayland-devel mailing list