* syscalls.cc (popen): Reorganize slightly for clarity. Fix a comment.
This commit is contained in:
parent
d5c44ae231
commit
4315703af7
@ -1,3 +1,7 @@
|
|||||||
|
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>
|
2009-08-17 Christopher Faylor <me+cygwin@cgf.cx>
|
||||||
|
|
||||||
* syscalls.cc (popen): Rewrite to accommodate situations where stdin,
|
* syscalls.cc (popen): Rewrite to accommodate situations where stdin,
|
||||||
|
@ -3631,10 +3631,7 @@ popen (const char *command, const char *in_type)
|
|||||||
if (pipe (fds) < 0)
|
if (pipe (fds) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
int orig_fds[2] = {fds[0], fds[1]};
|
|
||||||
int myix = rw == 'r' ? 0 : 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;
|
lock_process now;
|
||||||
FILE *fp = fdopen (fds[myix], in_type);
|
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
|
spawn_guts because spawn_guts is likely to be a more frequently
|
||||||
used routine and having stdin/stdout/stderr closed and reassigned
|
used routine and having stdin/stdout/stderr closed and reassigned
|
||||||
to pipe handles is an unlikely event. */
|
to pipe handles is an unlikely event. */
|
||||||
|
int orig_fds[2] = {fds[0], fds[1]};
|
||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
if (fds[i] <= 2)
|
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
|
int stdchild = myix ^ 1; /* stdchild denotes the index into fd for the
|
||||||
handle which will be redirected to
|
handle which will be redirected to
|
||||||
stdin/stdout */
|
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] =
|
const char *argv[4] =
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user