summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/tmux.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2010-07-11 17:06:45 +0000
committernicm <nicm@openbsd.org>2010-07-11 17:06:45 +0000
commit3c9f218d411024f3dfaff15b0b39b7a689a87c2f (patch)
tree07e2289865737116e45f40c51716451b315bb1c4 /usr.bin/tmux/tmux.c
parentbcrypt_gensalt is already declared in pwd.h (diff)
downloadwireguard-openbsd-3c9f218d411024f3dfaff15b0b39b7a689a87c2f.tar.xz
wireguard-openbsd-3c9f218d411024f3dfaff15b0b39b7a689a87c2f.zip
Return the command client return code with MSG_EXIT now that MSG_ERROR and
MSG_PRINT are unused. New clients should be compatible with old tmux servers but vice versa may print an error.
Diffstat (limited to 'usr.bin/tmux/tmux.c')
-rw-r--r--usr.bin/tmux/tmux.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c
index 9f80e5a0b7d..644412deaf9 100644
--- a/usr.bin/tmux/tmux.c
+++ b/usr.bin/tmux/tmux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.c,v 1.83 2010/06/28 22:10:42 nicm Exp $ */
+/* $OpenBSD: tmux.c,v 1.84 2010/07/11 17:06:45 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -61,7 +61,6 @@ char *makesockpath(const char *);
__dead void shell_exec(const char *, const char *);
struct imsgbuf *main_ibuf;
-int main_exitval;
void main_signal(int, short, unused void *);
void main_callback(int, short, void *);
@@ -548,7 +547,6 @@ main(int argc, char **argv)
events |= EV_WRITE;
event_once(main_ibuf->fd, events, main_callback, shellcmd, NULL);
- main_exitval = 0;
event_dispatch();
clear_signals();
@@ -597,6 +595,7 @@ main_dispatch(const char *shellcmd)
struct imsg imsg;
ssize_t n, datalen;
struct msg_shell_data shelldata;
+ struct msg_exit_data exitdata;
if ((n = imsg_read(main_ibuf)) == -1 || n == 0)
fatalx("imsg_read failed");
@@ -611,10 +610,13 @@ main_dispatch(const char *shellcmd)
switch (imsg.hdr.type) {
case MSG_EXIT:
case MSG_SHUTDOWN:
- if (datalen != 0)
- fatalx("bad MSG_EXIT size");
-
- exit(main_exitval);
+ if (datalen != sizeof exitdata) {
+ if (datalen != 0)
+ fatalx("bad MSG_EXIT size");
+ exit(0);
+ }
+ memcpy(&exitdata, imsg.data, sizeof exitdata);
+ exit(exitdata.retcode);
case MSG_READY:
if (datalen != 0)
fatalx("bad MSG_READY size");