diff options
author | Tiago Cunha <tcunha@gmx.com> | 2010-02-02 23:51:04 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2010-02-02 23:51:04 +0000 |
commit | 495a3056e98b8f67f6a7d47766f354b67d2622d9 (patch) | |
tree | 5836e33eddc96eb8893e466221cade4b75fe4861 /cmd-list.c | |
parent | 3116e3ce2173d5344abeb3f758d6278235a04bc9 (diff) | |
download | rtmux-495a3056e98b8f67f6a7d47766f354b67d2622d9.tar.gz rtmux-495a3056e98b8f67f6a7d47766f354b67d2622d9.tar.bz2 rtmux-495a3056e98b8f67f6a7d47766f354b67d2622d9.zip |
Sync OpenBSD patchset 626:
Don't stop parsing command sequences when a command requests the client to
stick around (attach-session/new-session).
Diffstat (limited to 'cmd-list.c')
-rw-r--r-- | cmd-list.c | 29 |
1 files changed, 24 insertions, 5 deletions
@@ -1,4 +1,4 @@ -/* $Id: cmd-list.c,v 1.6 2009-07-28 22:12:16 tcunha Exp $ */ +/* $Id: cmd-list.c,v 1.7 2010-02-02 23:51:04 tcunha Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -77,13 +77,32 @@ int cmd_list_exec(struct cmd_list *cmdlist, struct cmd_ctx *ctx) { struct cmd *cmd; - int n; + int n, retval; + retval = 0; TAILQ_FOREACH(cmd, cmdlist, qentry) { - if ((n = cmd_exec(cmd, ctx)) != 0) - return (n); + if ((n = cmd_exec(cmd, ctx)) == -1) + return (-1); + + /* + * A 1 return value means the command client is being attached + * (sent MSG_READY). + */ + if (n == 1) { + retval = 1; + + /* + * The command client has been attached, so mangle the + * context to treat any following commands as if they + * were called from inside. + */ + if (ctx->curclient == NULL) { + ctx->curclient = ctx->cmdclient; + ctx->cmdclient = NULL; + } + } } - return (0); + return (retval); } void |