diff --git a/src/common/init.c b/src/common/init.c index 8e27ebaf1..fe7544245 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -92,10 +92,6 @@ static void exitSignalHandler(FF_MAYBE_UNUSED int signal) resetConsole(); exit(0); } -static void chldSignalHandler(FF_MAYBE_UNUSED int signal) -{ - // empty; used to interrupt the poll and read syscalls -} #endif void ffStart(void) @@ -121,7 +117,10 @@ void ffStart(void) sigaction(SIGINT, &action, NULL); sigaction(SIGTERM, &action, NULL); sigaction(SIGQUIT, &action, NULL); - sigaction(SIGCHLD, &(struct sigaction) { .sa_handler = chldSignalHandler }, NULL); + sigset_t newmask; + sigemptyset(&newmask); + sigaddset(&newmask, SIGCHLD); + sigprocmask(SIG_BLOCK, &newmask, NULL); #endif //reset everything to default before we start printing diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index c4139ff4b..7ddd725da 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -184,30 +184,13 @@ const char* ffProcessReadOutput(FFProcessHandle* handle, FFstrbuf* buffer) waitpid(childPid, NULL, 0); return "poll(&pollfd, 1, timeout) timeout (try increasing --processing-timeout)"; } - else if (pollret < 0) - { - if (errno == EINTR) - { - // The child process has been terminated. See `chldSignalHandler` in `common/init.c` - if (waitpid(childPid, NULL, WNOHANG) == childPid) - { - // Read remaining data from the pipe - fcntl(childPipeFd, F_SETFL, O_CLOEXEC | O_NONBLOCK); - childPid = -1; - } - } - else - { - kill(childPid, SIGTERM); - waitpid(childPid, NULL, 0); - return "poll(&pollfd, 1, timeout) error: not EINTR"; - } - } - else if (pollfd.revents & POLLERR) + else if (pollret < 0 || (pollfd.revents & POLLERR)) { kill(childPid, SIGTERM); waitpid(childPid, NULL, 0); - return "poll(&pollfd, 1, timeout) error: POLLERR"; + return pollret < 0 + ? "poll(&pollfd, 1, timeout) error: pollret < 0" + : "poll(&pollfd, 1, timeout) error: pollfd.revents & POLLERR"; } } @@ -229,12 +212,7 @@ const char* ffProcessReadOutput(FFProcessHandle* handle, FFstrbuf* buffer) return NULL; } else if (nRead < 0) - { - if (errno == EAGAIN) - return NULL; - else - break; - } + break; } return "read(childPipeFd, str, FF_PIPE_BUFSIZ) failed";