summaryrefslogtreecommitdiffstats
path: root/job.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2011-01-08 01:52:36 +0000
committerNicholas Marriott <nicm@openbsd.org>2011-01-08 01:52:36 +0000
commit69cb1f830e4fd2282ddcbc7ee2bbe30069b9e4cd (patch)
tree49efff28238bbba524974db0512859a310d0b09c /job.c
parent703160b5d6b64e45a684894260693c60b5524d51 (diff)
Move all calls to fcntl(...O_NONBLOCK) into a function and clear the
flag on the stdio file descriptors before closing them (fixes things like "tmux ls && cat").
Diffstat (limited to 'job.c')
-rw-r--r--job.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/job.c b/job.c
index ef4066e5..c7181964 100644
--- a/job.c
+++ b/job.c
@@ -137,7 +137,7 @@ job_free(struct job *job)
int
job_run(struct job *job)
{
- int nullfd, out[2], mode;
+ int nullfd, out[2];
if (job->fd != -1 || job->pid != -1)
return (0);
@@ -177,10 +177,7 @@ job_run(struct job *job)
close(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)
- fatal("fcntl failed");
+ setblocking(job->fd, 0);
if (job->event != NULL)
bufferevent_free(job->event);