summaryrefslogtreecommitdiffstats
path: root/stream.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-03-11 20:07:16 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-03-11 20:07:16 -0700
commit23a2f7ca3b960cb563e5003fae88eda7278a0021 (patch)
tree7b2d862fcd886fe671f17307947bb539bc9c580c /stream.c
parentfbb9921f8d29350fbc69e568f90cd66379502e9c (diff)
downloadtxr-23a2f7ca3b960cb563e5003fae88eda7278a0021.tar.gz
txr-23a2f7ca3b960cb563e5003fae88eda7278a0021.tar.bz2
txr-23a2f7ca3b960cb563e5003fae88eda7278a0021.zip
* stream.c (open_process): Close the original pipe file descriptor
in the child process after dup2-ing it to standard input or standard output, so the child doesn't have to references to the pipe.
Diffstat (limited to 'stream.c')
-rw-r--r--stream.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/stream.c b/stream.c
index 7d073fc1..dbe3e9ff 100644
--- a/stream.c
+++ b/stream.c
@@ -2158,9 +2158,13 @@ val open_process(val name, val mode_str, val args)
if (pid == 0) {
if (input) {
dup2(fd[1], STDOUT_FILENO);
+ if (fd[1] != STDOUT_FILENO) /* You never know */
+ close(fd[1]);
close(fd[0]);
} else {
dup2(fd[0], STDIN_FILENO);
+ if (fd[0] != STDIN_FILENO) /* You never know */
+ close(fd[0]);
close(fd[1]);
}