=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/client.c,v retrieving revision 1.159 retrieving revision 1.160 diff -u -r1.159 -r1.160 --- src/usr.bin/tmux/client.c 2023/01/06 07:09:27 1.159 +++ src/usr.bin/tmux/client.c 2023/07/10 09:35:46 1.160 @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.159 2023/01/06 07:09:27 nicm Exp $ */ +/* $OpenBSD: client.c,v 1.160 2023/07/10 09:35:46 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -526,11 +526,22 @@ { 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 {