diff options
author | Marius Vlad <marius.vlad@collabora.com> | 2022-09-20 14:34:31 +0300 |
---|---|---|
committer | Marius Vlad <marius.vlad@collabora.com> | 2022-09-23 18:15:11 +0300 |
commit | e8761762fcd03d3f561c0a0b761d609ded41c8c3 (patch) | |
tree | ec2c4700021d69e8a95ffc8bb895b9b1de1ddf55 /src/shell.c | |
parent | 315496ddbb9f6f6079c8cd413507e15d41c3a5e7 (diff) |
compositor: Add missing SIGCHLD handler
We seem to be missing a SIGCHLD signal handlers so this patch
adds one similarity to what weston has.
Bug-AGL: SPEC-4570
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Change-Id: I137af4199c3d543fed940bbe289989095b114b74
Diffstat (limited to 'src/shell.c')
-rw-r--r-- | src/shell.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/shell.c b/src/shell.c index cb6e592..96f5c63 100644 --- a/src/shell.c +++ b/src/shell.c @@ -33,6 +33,7 @@ #include <string.h> #include <sys/socket.h> #include <sys/types.h> +#include <sys/wait.h> #include <unistd.h> #include <libweston/libweston.h> #include <libweston/config-parser.h> @@ -928,6 +929,37 @@ struct process_info { char *path; }; +int +sigchld_handler(int signal_number, void *data) +{ + struct weston_process *p; + struct ivi_compositor *ivi = data; + int status; + pid_t pid; + + while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { + wl_list_for_each(p, &ivi->child_process_list, link) { + if (p->pid == pid) + break; + } + + if (&p->link == &ivi->child_process_list) { + weston_log("unknown child process exited\n"); + continue; + } + + wl_list_remove(&p->link); + wl_list_init(&p->link); + p->cleanup(p, status); + } + + if (pid < 0 && errno != ECHILD) + weston_log("waitpid error %s\n", strerror(errno)); + + return 1; +} + + static void process_handle_sigchld(struct weston_process *process, int status) { |