summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2023-07-10 09:35:47 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2023-07-10 09:35:47 +0000
commit556f2331b5e77168be6fb61cb5b4a6e79e6e43e9 (patch)
treeb277e33e2238334179f95e52e56b0ad90d72dce3
parent12dc1a17e314f25ef6f9b17c780c6cc12cb5bdbd (diff)
Loop around waitpid in client, from Azat Khuzhin.
-rw-r--r--usr.bin/tmux/client.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/usr.bin/tmux/client.c b/usr.bin/tmux/client.c
index b5c4d36db39..16373e5d3d6 100644
--- a/usr.bin/tmux/client.c
+++ b/usr.bin/tmux/client.c
@@ -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 <nicholas.marriott@gmail.com>
@@ -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 {