diff options
author | Christopher Faylor <me@cgf.cx> | 2009-08-18 01:51:35 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2009-08-18 01:51:35 +0000 |
commit | 4315703af7e147836cd6c5e73232d5522d26dc6e (patch) | |
tree | f3fa137757dce08f1cdb9d437c3c859a165fe67b /winsup/cygwin/syscalls.cc | |
parent | d5c44ae231f7dd38225df7acc0a14189ee03304a (diff) | |
download | cygnal-4315703af7e147836cd6c5e73232d5522d26dc6e.tar.gz cygnal-4315703af7e147836cd6c5e73232d5522d26dc6e.tar.bz2 cygnal-4315703af7e147836cd6c5e73232d5522d26dc6e.zip |
* syscalls.cc (popen): Reorganize slightly for clarity. Fix a comment.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r-- | winsup/cygwin/syscalls.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 90a0a9cd8..8fc806f88 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -3631,10 +3631,7 @@ popen (const char *command, const char *in_type) if (pipe (fds) < 0) return NULL; - int orig_fds[2] = {fds[0], fds[1]}; int myix = rw == 'r' ? 0 : 1; - int __std[2]; - __std[myix] = -1; /* -1 denotes don't pass this fd to child process */ lock_process now; FILE *fp = fdopen (fds[myix], in_type); @@ -3646,6 +3643,7 @@ popen (const char *command, const char *in_type) spawn_guts because spawn_guts is likely to be a more frequently used routine and having stdin/stdout/stderr closed and reassigned to pipe handles is an unlikely event. */ + int orig_fds[2] = {fds[0], fds[1]}; for (int i = 0; i < 2; i++) if (fds[i] <= 2) { @@ -3659,7 +3657,10 @@ popen (const char *command, const char *in_type) int stdchild = myix ^ 1; /* stdchild denotes the index into fd for the handle which will be redirected to stdin/stdout */ - __std[stdchild] = fds[stdchild]; + int __std[2]; + __std[myix] = -1; /* -1 means don't pass this fd to the child + process */ + __std[stdchild] = fds[stdchild]; /* Do pass this as the std handle */ const char *argv[4] = { |