summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2022-04-02 00:33:29 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2022-04-02 00:47:46 +0200
commitf4c4b97bba99c7848bf3cda287564db8219b0f40 (patch)
treeabe969e8bb90888bf7af3cd4766df26c33483939
parent3eb3533fae6c43907adbd340b24bee79f709504e (diff)
sfeed_curses: line editor: handle SIGCHLD directly
This makes sure when processes exit they are reaped immediately (instead of after closing the line editor).
-rw-r--r--sfeed_curses.c9
1 files changed, 8 insertions, 1 deletions
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 */