diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-03-11 20:07:16 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-03-11 20:07:16 -0700 |
commit | 23a2f7ca3b960cb563e5003fae88eda7278a0021 (patch) | |
tree | 7b2d862fcd886fe671f17307947bb539bc9c580c | |
parent | fbb9921f8d29350fbc69e568f90cd66379502e9c (diff) | |
download | txr-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.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | stream.c | 4 |
2 files changed, 10 insertions, 0 deletions
@@ -1,3 +1,9 @@ +2014-03-11 Kaz Kylheku <kaz@kylheku.com> + + * 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. + 2014-03-10 Kaz Kylheku <kaz@kylheku.com> * stream.c (pipe_close): Restructured the function a bit. @@ -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]); } |