From 33ae34357f371f45ecb5f988bcdd961372130565 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Sun, 27 Mar 2022 12:32:31 +0200 Subject: sfeed_curses: avoid non-interactive plumb process becoming a zombie From POSIX: Consequences of Process Termination: https://pubs.opengroup.org/onlinepubs/9699919799/functions/_Exit.html#tag_16_01_03_01 " [XSI] [Option Start] If the parent process of the calling process has set its SA_NOCLDWAIT flag or has set the action for the SIGCHLD signal to SIG_IGN: The process' status information (see Status Information), if any, shall be discarded. The lifetime of the calling process shall end immediately. If SA_NOCLDWAIT is set, it is implementation-defined whether a SIGCHLD signal is sent to the parent process. If a thread in the parent process of the calling process is blocked in wait(), waitpid(), or waitid(), and the parent process has no remaining child processes in the set of waited-for children, the wait(), waitid(), or waitpid() function shall fail and set errno to [ECHILD]. " Noticed on Linux (but not on OpenBSD). To reproduce: - SFEED_PLUMBER_INTERACTIVE=0 SFEED_PLUMBER="less" sfeed_curses ~/.sfeed/feeds/* - Then open and close the child program. - Notice it becoming a zombie or "" in the process table. --- sfeed_curses.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sfeed_curses.c b/sfeed_curses.c index 0d878f7..6f151d4 100644 --- a/sfeed_curses.c +++ b/sfeed_curses.c @@ -558,6 +558,9 @@ init(void) sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); sigaction(SIGWINCH, &sa, NULL); + /* ignore SIGCHLD: for non-interactive programs: don't become a zombie */ + sa.sa_handler = SIG_IGN; + sigaction(SIGCHLD, &sa, NULL); } void -- cgit v1.2.3