=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/job.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- src/usr.bin/tmux/job.c 2009/10/20 22:15:32 1.6 +++ src/usr.bin/tmux/job.c 2009/10/21 07:24:23 1.7 @@ -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 @@ -153,13 +153,13 @@ 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 @@ 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)