summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2009-10-21 07:24:24 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2009-10-21 07:24:24 +0000
commit60687b0548f29c9642a9610f4269ef1f70d74572 (patch)
treef997259ccf8441719e7ddc4a3e6de8c7d7be008f /usr.bin
parent202ea4da2d349d1a47eb6a0aa0625c167e04ef13 (diff)
Getting the read and write ends of the pipe the right way round is usually
recommended. DOH.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/job.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/usr.bin/tmux/job.c b/usr.bin/tmux/job.c
index a264c9ac6f9..9f8e39375fe 100644
--- a/usr.bin/tmux/job.c
+++ b/usr.bin/tmux/job.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: job.c,v 1.6 2009/10/20 22:15:32 nicm Exp $ */
+/* $OpenBSD: job.c,v 1.7 2009/10/21 07:24:23 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -153,13 +153,13 @@ job_run(struct job *job)
sigreset();
/* XXX environ? */
- close(out[1]);
- if (dup2(out[0], STDOUT_FILENO) == -1)
+ if (dup2(out[1], STDOUT_FILENO) == -1)
fatal("dup2 failed");
- if (out[0] != STDOUT_FILENO)
- close(out[0]);
+ if (out[1] != STDOUT_FILENO)
+ close(out[1]);
+ close(out[0]);
- nullfd = open(_PATH_DEVNULL, O_RDONLY, 0);
+ nullfd = open(_PATH_DEVNULL, O_RDWR, 0);
if (nullfd < 0)
fatal("open failed");
if (dup2(nullfd, STDIN_FILENO) == -1)
@@ -172,9 +172,9 @@ job_run(struct job *job)
execl(_PATH_BSHELL, "sh", "-c", job->cmd, (char *) NULL);
fatal("execl failed");
default: /* parent */
- close(out[0]);
+ close(out[1]);
- job->fd = out[1];
+ job->fd = out[0];
if ((mode = fcntl(job->fd, F_GETFL)) == -1)
fatal("fcntl failed");
if (fcntl(job->fd, F_SETFL, mode|O_NONBLOCK) == -1)