diff options
author | Andrei Makeev <amaksoft@gmail.com> | 2022-12-08 13:53:24 +0000 |
---|---|---|
committer | Daniel Stone <daniels@collabora.com> | 2022-12-30 14:06:22 +0000 |
commit | 5b7561b25d7db05839def4d69e2ca1f3a1e18e56 (patch) | |
tree | 17e5c3ede591712755380e4b1012d50dfb9e2662 /compositor | |
parent | ab1a3c81648642e359bcf43d2ec2788d255d0986 (diff) | |
download | weston-5b7561b25d7db05839def4d69e2ca1f3a1e18e56.tar.gz |
compositor: don't pass the signal flags to autolaunched process
Signed-off-by: Andrei Makeev <amaksoft@gmail.com>
Diffstat (limited to 'compositor')
-rw-r--r-- | compositor/main.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/compositor/main.c b/compositor/main.c index 47de4179..c31dccf8 100644 --- a/compositor/main.c +++ b/compositor/main.c @@ -370,6 +370,23 @@ sigchld_handler(int signal_number, void *data) return 1; } +static void +cleanup_for_child_process() { + sigset_t allsigs; + + /* 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(); + + /* do not give our signal mask to the new process */ + sigfillset(&allsigs); + sigprocmask(SIG_UNBLOCK, &allsigs, NULL); +} + WL_EXPORT struct wl_client * weston_client_launch(struct weston_compositor *compositor, struct weston_process *proc, @@ -384,7 +401,6 @@ weston_client_launch(struct weston_compositor *compositor, char *fail_exec; char * const *argp; char * const *envp; - sigset_t allsigs; pid_t pid; bool ret; size_t written __attribute__((unused)); @@ -413,17 +429,7 @@ weston_client_launch(struct weston_compositor *compositor, pid = fork(); switch (pid) { case 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(); - - /* do not give our signal mask to the new process */ - sigfillset(&allsigs); - sigprocmask(SIG_UNBLOCK, &allsigs, NULL); + cleanup_for_child_process(); /* Launch clients as the user. Do not launch clients with wrong euid. */ if (seteuid(getuid()) == -1) { @@ -3545,6 +3551,7 @@ execute_autolaunch(struct wet_compositor *wet, struct weston_config *config) weston_log("Failed to fork autolaunch process: %s\n", strerror(errno)); goto out; } else if (tmp_pid == 0) { + cleanup_for_child_process(); execl(autolaunch_path, autolaunch_path, NULL); /* execl shouldn't return */ fprintf(stderr, "Failed to execute autolaunch: %s\n", strerror(errno)); |