summaryrefslogtreecommitdiffstats
path: root/cmd-run-shell.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2010-07-24 20:11:59 +0000
committerNicholas Marriott <nicm@openbsd.org>2010-07-24 20:11:59 +0000
commitc87187f913f853a650a00ca0328817987298f7d0 (patch)
tree41315e86224393a16a23460034da98991dfbf656 /cmd-run-shell.c
parentbf09b00fe946a06c2f1192bd213f26e5a47889a8 (diff)
When changing so that the client passes its stdout and stderr as well as
stdin up to the server, I forgot one essential point - the tmux server could now be both the producer and consumer. This happens when tmux is run inside tmux, as well as when piping tmux commands together. So, using stdio(3) was a bad idea - if sufficient data was written, this could block in write(2). When that happened and the server was both producer and consumer, it deadlocks. Change to use libevent bufferevents for the client stdin, stdout and stderr instead. This is trivial enough for output but requires a callback mechanism to trigger when stdin is finished. This relies on the underlying polling mechanism for libevent to work with whatever devices to which the user could redirect stdin, stdout or stderr, hence the change to use poll(2) over kqueue(2) for tmux.
Diffstat (limited to 'cmd-run-shell.c')
-rw-r--r--cmd-run-shell.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/cmd-run-shell.c b/cmd-run-shell.c
index f9d1e237..7bfb8916 100644
--- a/cmd-run-shell.c
+++ b/cmd-run-shell.c
@@ -131,13 +131,10 @@ cmd_run_shell_free(void *data)
{
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--;
- exitdata.retcode = ctx->cmdclient->retcode;
- server_write_client(
- ctx->cmdclient, MSG_EXIT, &exitdata, sizeof exitdata);
+ ctx->cmdclient->flags |= CLIENT_EXIT;
}
if (ctx->curclient != NULL)
ctx->curclient->references--;