summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Straz <nstraz@redhat.com>2013-12-19 14:21:57 -0500
committerNathan Straz <nstraz@redhat.com>2013-12-19 14:21:57 -0500
commit5a817b5216bf4aa6e453f6716b410ef88142619c (patch)
tree10afe1f3f671f50b336591a1b4cc7a9d09102b8b
parent8c776377580eab346eff881da4111e42a8c12e57 (diff)
downloadqarsh-5a817b5216bf4aa6e453f6716b410ef88142619c.zip
qarsh-5a817b5216bf4aa6e453f6716b410ef88142619c.tar.gz
qarsh-5a817b5216bf4aa6e453f6716b410ef88142619c.tar.xz
Don't check childfds after we've closed one.
This was hitting easily on RHEL5 systems
-rw-r--r--qarshd.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/qarshd.c b/qarshd.c
index 255defe..49e763d 100644
--- a/qarshd.c
+++ b/qarshd.c
@@ -349,7 +349,7 @@ handle_qarsh()
nfd--;
qpfree(qp);
}
- if (nfd && FD_ISSET(childfds[0], &wfds)) {
+ if (nfd && childfds[0] != -1 && FD_ISSET(childfds[0], &wfds)) {
/* Child is ready for data on stdin */
nbytes = write(childfds[0], buf_in, z_in);
if (nbytes == -1) { /* Don't try writing to the child again */
@@ -375,7 +375,7 @@ handle_qarsh()
}
nfd--;
}
- if (nfd && FD_ISSET(childfds[1], &rfds)) {
+ if (nfd && childfds[1] != -1 && FD_ISSET(childfds[1], &rfds)) {
/* Child has something to send to stdout */
nbytes = read(childfds[1], buf, allowed_out);
qp = make_qp_data(1, nbytes, buf);
@@ -389,7 +389,7 @@ handle_qarsh()
}
nfd--;
}
- if (nfd && FD_ISSET(childfds[2], &rfds)) {
+ if (nfd && childfds[2] != -1 && FD_ISSET(childfds[2], &rfds)) {
/* Child has something to send to stderr */
nbytes = read(childfds[2], buf, allowed_err);
qp = make_qp_data(2, nbytes, buf);