summaryrefslogtreecommitdiffstats
path: root/client.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 03:34:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 03:34:56 +0000
commitc294c2bf54a3ec56271a78c284f84e75a8119731 (patch)
treef1fed2d81b80619666e9508fa5051bcfc34fae5f /client.c
parentReleasing progress-linux version 3.3a-5~progress7.99u1. (diff)
downloadtmux-c294c2bf54a3ec56271a78c284f84e75a8119731.tar.xz
tmux-c294c2bf54a3ec56271a78c284f84e75a8119731.zip
Merging upstream version 3.4.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'client.c')
-rw-r--r--client.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/client.c b/client.c
index df6cee9..9cd5ad8 100644
--- a/client.c
+++ b/client.c
@@ -245,9 +245,6 @@ client_main(struct event_base *base, int argc, char **argv, uint64_t flags,
u_int ncaps = 0;
struct args_value *values;
- /* Ignore SIGCHLD now or daemon() in the server will leave a zombie. */
- signal(SIGCHLD, SIG_IGN);
-
/* Set up the initial command. */
if (shell_command != NULL) {
msg = MSG_SHELL;
@@ -284,6 +281,12 @@ client_main(struct event_base *base, int argc, char **argv, uint64_t flags,
log_debug("flags are %#llx", (unsigned long long)client_flags);
/* Initialize the client socket and start the server. */
+#ifdef HAVE_SYSTEMD
+ if (systemd_activated()) {
+ /* socket-based activation, do not even try to be a client. */
+ fd = server_start(client_proc, flags, base, 0, NULL);
+ } else
+#endif
fd = client_connect(base, socket_path, client_flags);
if (fd == -1) {
if (errno == ECONNREFUSED) {
@@ -527,11 +530,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 {
@@ -694,6 +708,9 @@ client_dispatch_wait(struct imsg *imsg)
!(client_flags & CLIENT_CONTROL), client_file_check_cb,
NULL);
break;
+ case MSG_READ_CANCEL:
+ file_read_cancel(&client_files, imsg);
+ break;
case MSG_WRITE_OPEN:
file_write_open(&client_files, client_peer, imsg, 1,
!(client_flags & CLIENT_CONTROL), client_file_check_cb,