From bb1d19dc5e99a65bd1aa250342778a1db21c6093 Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Thu, 7 Apr 2022 11:04:44 -0500 Subject: [PATCH] compositor: Launch clients in their own session When we launch clients they currently stay in the same session as weston, and share its controlling terminal. This means hitting ctrl-c in weston's controlling terminal will send SIGINT to the clients as well. It also means SIGHUP will be propagated to our launched clients if weston's controlling terminal is closed. While generally not harmful, this behaviour is not beneficial, and is present by default and not by design. Problems arise when launching weston in a debugger, as a ctrl-c sent to the debugger will be propagated not only to the debugger, but all the child processes sharing weston's session. This results in weston-desktop-shell being killed by the ctrl-c that was intended to stop weston for debugging. If weston-desktop-shell is killed within 30 second of startup, it will result weston performing a clean shutdown. This clean shutdown can make debugging a little too surprising. Ostensibly, clients launched via weston_client_launch will be wayland clients that terminate cleanly on their own if weston is killed, so there should be no need for them to remain in weston's session to catch ctrl-c from its controlling terminal. Nor should they need a controlling terminal for their general operation. Use setsid() to move them to their own session, devoid of controlling terminal, to make using a debugger a little less confusing in some cases. Signed-off-by: Derek Foreman --- compositor/main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/compositor/main.c b/compositor/main.c index cba8dfd5..1b7e01fe 100644 --- a/compositor/main.c +++ b/compositor/main.c @@ -427,6 +427,13 @@ weston_client_launch(struct weston_compositor *compositor, } if (pid == 0) { + /* Put the client in a new session so it won't catch signals + * intended for the parent. Sharing a session can be + * confusing when launching weston under gdb, as the ctrl-c + * intended for gdb will pass to the child, and weston + * will cleanly shut down when the child exits. + */ + setsid(); child_client_exec(sv[1], path); _exit(-1); }