Update of /cvsroot/tmux/tmux
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv18439

Modified Files:
        cmd-if-shell.c cmd-run-shell.c server-client.c tmux.c tmux.h 
Log Message:
Sync OpenBSD patchset 734:

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.


Index: server-client.c
===================================================================
RCS file: /cvsroot/tmux/tmux/server-client.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- server-client.c     2 Jul 2010 02:52:13 -0000       1.34
+++ server-client.c     17 Jul 2010 14:36:40 -0000      1.35
@@ -663,6 +663,8 @@
 
        fputc('\n', ctx->cmdclient->stderr_file);
        fflush(ctx->cmdclient->stderr_file);
+
+       ctx->cmdclient->retcode = 1;
 }
 
 /* Callback to send print message to client. */
@@ -700,10 +702,11 @@
 void
 server_client_msg_command(struct client *c, struct msg_command_data *data)
 {
-       struct cmd_ctx   ctx;
-       struct cmd_list *cmdlist = NULL;
-       int              argc;
-       char           **argv, *cause;
+       struct cmd_ctx          ctx;
+       struct cmd_list        *cmdlist = NULL;
+       struct msg_exit_data    exitdata;
+       int                     argc;
+       char                  **argv, *cause;
 
        ctx.error = server_client_msg_error;
        ctx.print = server_client_msg_print;
@@ -734,15 +737,18 @@
        }
        cmd_free_argv(argc, argv);
 
-       if (cmd_list_exec(cmdlist, &ctx) != 1)
-               server_write_client(c, MSG_EXIT, NULL, 0);
+       if (cmd_list_exec(cmdlist, &ctx) != 1) {
+               exitdata.retcode = c->retcode;
+               server_write_client(c, MSG_EXIT, &exitdata, sizeof exitdata);
+       }
        cmd_list_free(cmdlist);
        return;
 
 error:
        if (cmdlist != NULL)
                cmd_list_free(cmdlist);
-       server_write_client(c, MSG_EXIT, NULL, 0);
+       exitdata.retcode = c->retcode;
+       server_write_client(c, MSG_EXIT, &exitdata, sizeof exitdata);
 }
 
 /* Handle identify message. */

Index: cmd-run-shell.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-run-shell.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- cmd-run-shell.c     6 Jun 2010 00:04:59 -0000       1.7
+++ cmd-run-shell.c     17 Jul 2010 14:36:40 -0000      1.8
@@ -131,10 +131,13 @@
 {
        struct cmd_run_shell_data       *cdata = data;
        struct cmd_ctx                  *ctx = &cdata->ctx;
+       struct msg_exit_data             exitdata;
 
        if (ctx->cmdclient != NULL) {
                ctx->cmdclient->references--;
-               server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
+               exitdata.retcode = ctx->cmdclient->retcode;
+               server_write_client(
+                   ctx->cmdclient, MSG_EXIT, &exitdata, sizeof exitdata);
        }
        if (ctx->curclient != NULL)
                ctx->curclient->references--;

Index: tmux.c
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.c,v
retrieving revision 1.213
retrieving revision 1.214
diff -u -d -r1.213 -r1.214
--- tmux.c      2 Jul 2010 02:52:13 -0000       1.213
+++ tmux.c      17 Jul 2010 14:36:41 -0000      1.214
@@ -60,7 +60,6 @@
 __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 *);
@@ -565,7 +564,6 @@
                events |= EV_WRITE;
        event_once(main_ibuf->fd, events, main_callback, shellcmd, NULL);
 
-       main_exitval = 0;
        event_dispatch();
 
        clear_signals();
@@ -614,6 +612,7 @@
        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");
@@ -628,10 +627,13 @@
                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");

Index: tmux.h
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.h,v
retrieving revision 1.569
retrieving revision 1.570
diff -u -d -r1.569 -r1.570
--- tmux.h      2 Jul 2010 02:56:07 -0000       1.569
+++ tmux.h      17 Jul 2010 14:36:41 -0000      1.570
@@ -412,6 +412,10 @@
        char            shell[MAXPATHLEN];
 };
 
+struct msg_exit_data {
+       int             retcode;
+};
+
 /* Mode key commands. */
 enum mode_key_cmd {
        MODEKEY_NONE,
@@ -1080,6 +1084,7 @@
 struct client {
        struct imsgbuf   ibuf;
        struct event     event;
+       int              retcode;
 
        struct timeval   creation_time;
        struct timeval   activity_time;

Index: cmd-if-shell.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-if-shell.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- cmd-if-shell.c      14 Nov 2009 17:56:39 -0000      1.8
+++ cmd-if-shell.c      17 Jul 2010 14:36:40 -0000      1.9
@@ -104,10 +104,13 @@
 {
        struct cmd_if_shell_data        *cdata = data;
        struct cmd_ctx                  *ctx = &cdata->ctx;
+       struct msg_exit_data             exitdata;
 
        if (ctx->cmdclient != NULL) {
                ctx->cmdclient->references--;
-               server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
+               exitdata.retcode = ctx->cmdclient->retcode;
+               server_write_client(
+                   ctx->cmdclient, MSG_EXIT, &exitdata, sizeof exitdata);
        }
        if (ctx->curclient != NULL)
                ctx->curclient->references--;


------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to