From f4c4b97bba99c7848bf3cda287564db8219b0f40 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Sat, 2 Apr 2022 00:33:29 +0200 Subject: sfeed_curses: line editor: handle SIGCHLD directly This makes sure when processes exit they are reaped immediately (instead of after closing the line editor). --- sfeed_curses.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sfeed_curses.c b/sfeed_curses.c index a12b41f..03c38fe 100644 --- a/sfeed_curses.c +++ b/sfeed_curses.c @@ -1006,12 +1006,19 @@ lineeditor(void) ttywrite(&input[nchars]); nchars++; } else if (ch < 0) { + if (state_sigchld) { + state_sigchld = 0; + /* wait on child processes so they don't become a zombie */ + while (waitpid((pid_t)-1, NULL, WNOHANG) > 0) + ; + } if (state_sigint) - state_sigint = 0; /* reset: do not handle it later */ + state_sigint = 0; /* cancel prompt and don't handle this signal */ else if (state_sighup || state_sigterm) ; /* cancel prompt and handle these signals */ else /* no signal, time-out or SIGCHLD or SIGWINCH */ continue; /* do not cancel: process signal later */ + free(input); input = NULL; break; /* cancel prompt */ -- cgit v1.2.3