mirror of
https://repo.or.cz/socat.git
synced 2025-07-26 12:02:58 +00:00
fixed a bug where sub processes would become zombies because the master process caught SIGCHLD but did not wait()
This commit is contained in:
parent
1f5165b765
commit
3b3b004ff8
4 changed files with 84 additions and 1 deletions
28
xio-socket.c
28
xio-socket.c
|
@ -512,9 +512,37 @@ int _xioopen_dgram_sendto(/* them is already in xfd->peersa */
|
|||
static pid_t xio_waitingfor;
|
||||
static bool xio_hashappened;
|
||||
void xiosigaction_hasread(int signum, siginfo_t *siginfo, void *ucontext) {
|
||||
pid_t pid;
|
||||
int _errno;
|
||||
int status = 0;
|
||||
bool wassig = false;
|
||||
Debug5("xiosigaction_hasread(%d, {%d,%d,%d,"F_pid"}, )",
|
||||
signum, siginfo->si_signo, siginfo->si_errno, siginfo->si_code,
|
||||
siginfo->si_pid);
|
||||
_errno = errno;
|
||||
do {
|
||||
pid = Waitpid(-1, &status, WNOHANG);
|
||||
if (pid == 0) {
|
||||
Msg(wassig?E_INFO:E_WARN,
|
||||
"waitpid(-1, {}, WNOHANG): no child has exited");
|
||||
Info("childdied() finished");
|
||||
errno = _errno;
|
||||
return;
|
||||
} else if (pid < 0 && errno == ECHILD) {
|
||||
Msg1(wassig?E_INFO:E_WARN,
|
||||
"waitpid(-1, {}, WNOHANG): %s", strerror(errno));
|
||||
Info("childdied() finished");
|
||||
errno = _errno;
|
||||
return;
|
||||
}
|
||||
wassig = true;
|
||||
if (pid < 0) {
|
||||
Warn2("waitpid(-1, {%d}, WNOHANG): %s", status, strerror(errno));
|
||||
Info("childdied() finished");
|
||||
errno = _errno;
|
||||
return;
|
||||
}
|
||||
} while (1);
|
||||
if (xio_waitingfor == siginfo->si_pid) {
|
||||
xio_hashappened = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue