summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2022-03-27 12:32:31 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2022-03-27 12:32:31 +0200
commit33ae34357f371f45ecb5f988bcdd961372130565 (patch)
tree0c73ae588957961133af4c73420fd89bfdd2eff4
parentdb1dcafd03997127f2cbc82376e2cc8df9b77356 (diff)
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 "<defunct>" in the process table.
-rw-r--r--sfeed_curses.c3
1 files changed, 3 insertions, 0 deletions
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