summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);