diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-10-20 22:15:33 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-10-20 22:15:33 +0000 |
commit | fefdaa908c92564d5620af6bc82c77d9c5e92984 (patch) | |
tree | a86ca362baeacb3c54f8ba293914e6fa81bc99d1 /usr.bin/tmux | |
parent | c9d225057206c988d04b49087c249a66028f06c5 (diff) |
Sort out stdout before stdin/stderr in case the stdout side of the pipe got one
of their fds.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/job.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/usr.bin/tmux/job.c b/usr.bin/tmux/job.c index 130d6fa2b70..a264c9ac6f9 100644 --- a/usr.bin/tmux/job.c +++ b/usr.bin/tmux/job.c @@ -1,4 +1,4 @@ -/* $OpenBSD: job.c,v 1.5 2009/10/11 08:58:05 nicm Exp $ */ +/* $OpenBSD: job.c,v 1.6 2009/10/20 22:15:32 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -153,6 +153,12 @@ job_run(struct job *job) sigreset(); /* XXX environ? */ + close(out[1]); + if (dup2(out[0], STDOUT_FILENO) == -1) + fatal("dup2 failed"); + if (out[0] != STDOUT_FILENO) + close(out[0]); + nullfd = open(_PATH_DEVNULL, O_RDONLY, 0); if (nullfd < 0) fatal("open failed"); @@ -163,12 +169,6 @@ job_run(struct job *job) if (nullfd != STDIN_FILENO && nullfd != STDERR_FILENO) close(nullfd); - close(out[1]); - if (dup2(out[0], STDOUT_FILENO) == -1) - fatal("dup2 failed"); - if (out[0] != STDOUT_FILENO) - close(out[0]); - execl(_PATH_BSHELL, "sh", "-c", job->cmd, (char *) NULL); fatal("execl failed"); default: /* parent */ |