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:
Diffstat (limited to 'newlib/libc/posix/popen.c')
-rw-r--r--newlib/libc/posix/popen.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/newlib/libc/posix/popen.c b/newlib/libc/posix/popen.c
index faf72b6e3..38978c7aa 100644
--- a/newlib/libc/posix/popen.c
+++ b/newlib/libc/posix/popen.c
@@ -113,7 +113,7 @@ _DEFUN(popen, (program, type),
const char *program _AND
const char *type)
{
- struct pid *cur;
+ struct pid *cur, *last;
FILE *iop;
int pdes[2], pid;
@@ -159,7 +159,8 @@ _DEFUN(popen, (program, type),
(void)close(pdes[1]);
}
/* Close all fd's created by prior popen. */
- for (cur = pidlist; cur; cur = cur->next)
+ for (last = NULL, cur = pidlist; cur;
+ last = cur, cur = cur->next)
(void)close (fileno (cur->fp));
execl(_PATH_BSHELL, "sh", "-c", program, NULL);
_exit(127);