sfeed

Simple RSS and Atom feed parser
git clone https://git.sinitax.com/codemadness/sfeed
Log | Files | Refs | README | LICENSE | Upstream | sfeed.txt

commit 33ae34357f371f45ecb5f988bcdd961372130565
parent db1dcafd03997127f2cbc82376e2cc8df9b77356
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sun, 27 Mar 2022 12:32:31 +0200

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.

Diffstat:
Msfeed_curses.c | 3+++
1 file changed, 3 insertions(+), 0 deletions(-)

diff --git 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