Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2009-08-18 05:51:35 +0400
committerChristopher Faylor <me@cgf.cx>2009-08-18 05:51:35 +0400
commit4315703af7e147836cd6c5e73232d5522d26dc6e (patch)
treef3fa137757dce08f1cdb9d437c3c859a165fe67b /winsup/cygwin
parentd5c44ae231f7dd38225df7acc0a14189ee03304a (diff)
* syscalls.cc (popen): Reorganize slightly for clarity. Fix a comment.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/ChangeLog4
-rw-r--r--winsup/cygwin/syscalls.cc9
2 files changed, 9 insertions, 4 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 20087a915..e29a935b5 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,9 @@
2009-08-17 Christopher Faylor <me+cygwin@cgf.cx>
+ * syscalls.cc (popen): Reorganize slightly for clarity. Fix a comment.
+
+2009-08-17 Christopher Faylor <me+cygwin@cgf.cx>
+
* syscalls.cc (popen): Rewrite to accommodate situations where stdin,
stdout, or stderr are closed.
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] =
{