diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2010-01-30 19:08:47 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2010-01-30 19:08:47 +0000 |
commit | 8a37a1cc2d67c3ef9c3c42ddaa3b5dd1d57788ff (patch) | |
tree | e0fe6421d68ac55ac70434e258f3565c8f1d198a /cmd-list.c | |
parent | 65c9004550e03cad0250ae999594806962275002 (diff) | |
download | rtmux-8a37a1cc2d67c3ef9c3c42ddaa3b5dd1d57788ff.tar.gz rtmux-8a37a1cc2d67c3ef9c3c42ddaa3b5dd1d57788ff.tar.bz2 rtmux-8a37a1cc2d67c3ef9c3c42ddaa3b5dd1d57788ff.zip |
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 | 27 |
1 files changed, 23 insertions, 4 deletions
@@ -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 |