diff options
author | Jakub Jelinek <jakub@redhat.com> | 2007-07-31 17:46:17 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2007-07-31 17:46:17 +0000 |
commit | 8833066b122427710a9e14a888ce6cfa862332d3 (patch) | |
tree | 29591019d695919417b3698618d6a342e97381d6 /libio/iopopen.c | |
parent | fedca46896bdb702cb988837a0c2c5447e72ba2b (diff) |
Updated to fedora-glibc-20070731T1624cvs/fedora-glibc-2_6_90-1
Diffstat (limited to 'libio/iopopen.c')
-rw-r--r-- | libio/iopopen.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/libio/iopopen.c b/libio/iopopen.c index 896e930f40..d5c6305b09 100644 --- a/libio/iopopen.c +++ b/libio/iopopen.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1993, 1997-2002, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1997-2002, 2003, 2004, 2007 + Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Per Bothner <bothner@cygnus.com>. @@ -169,7 +170,15 @@ _IO_new_proc_open (fp, command, mode) popen() calls that remain open in the parent process are closed in the new child process." */ for (p = proc_file_chain; p; p = p->next) - _IO_close (_IO_fileno ((_IO_FILE *) p)); + { + int fd = _IO_fileno ((_IO_FILE *) p); + + /* If any stream from previous popen() calls has fileno + child_std_end, it has been already closed by the dup2 syscall + above. */ + if (fd != child_std_end) + _IO_close (fd); + } _IO_execl ("/bin/sh", "sh", "-c", command, (char *) 0); _IO__exit (127); |