From 2fe602a6a2b3816b2bf9be991ae52211dcd961bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 2 Nov 2020 19:15:42 +0100 Subject: [PATCH] =?UTF-8?q?main:=20no=20need=20to=20block=20SIGCHLD=20anym?= =?UTF-8?q?ore,=20we=20don=E2=80=99t=20use=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/main.c b/main.c index 61a89f1..f8a8453 100644 --- a/main.c +++ b/main.c @@ -279,11 +279,6 @@ main(int argc, char *const *argv) sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); - sigset_t proc_signal_mask; - sigemptyset(&proc_signal_mask); - sigaddset(&proc_signal_mask, SIGCHLD); - sigprocmask(SIG_BLOCK, &proc_signal_mask, NULL); - /* Block SIGINT (this is under the assumption that threads inherit * the signal mask */ sigset_t signal_mask; @@ -341,15 +336,17 @@ main(int argc, char *const *argv) while (!aborted) { struct pollfd fds[] = {{.fd = abort_fd, .events = POLLIN}}; - int r __attribute__((unused)) = poll(fds, 1, -1); + int r __attribute__((unused)) = poll(fds, sizeof(fds) / sizeof(fds[0]), -1); - /* - * Either the bar aborted (triggering the abort_fd), or user - * killed us (triggering the signal handler which sets - * 'aborted') - */ - assert(aborted || r == 1); - break; + if (fds[0].revents & (POLLIN | POLLHUP)) { + /* + * Either the bar aborted (triggering the abort_fd), or user + * killed us (triggering the signal handler which sets + * 'aborted') + */ + assert(aborted || r == 1); + break; + } } if (aborted)