diff options
author | nicm <nicm> | 2023-07-10 09:35:46 +0000 |
---|---|---|
committer | nicm <nicm> | 2023-07-10 09:35:46 +0000 |
commit | 4ece43a02961dc6726e97b05caca9a3c53793826 (patch) | |
tree | 0649754d687af7e9d8a50996502c9f2ca8202420 | |
parent | 8b3e2eab5afde62a4eb87b132b4196105c1cfaa6 (diff) |
Loop around waitpid in client, from Azat Khuzhin.
-rw-r--r-- | client.c | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -526,11 +526,22 @@ client_signal(int sig) { struct sigaction sigact; int status; + pid_t pid; log_debug("%s: %s", __func__, strsignal(sig)); - if (sig == SIGCHLD) - waitpid(WAIT_ANY, &status, WNOHANG); - else if (!client_attached) { + if (sig == SIGCHLD) { + for (;;) { + pid = waitpid(WAIT_ANY, &status, WNOHANG); + if (pid == 0) + break; + if (pid == -1) { + if (errno == ECHILD) + break; + log_debug("waitpid failed: %s", + strerror(errno)); + } + } + } else if (!client_attached) { if (sig == SIGTERM || sig == SIGHUP) proc_exit(client_proc); } else { |