From e26a5970cadb10b06977ddb5928c36d8b1be1367 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Tue, 11 Jun 2002 11:55:44 +0000 Subject: A patch from Ted Phelps to fix popen(). Ted writes: There is a minor bug in the implementation of popen(). In the case where the file descriptor returned from its call to pipe() is the same as the file descriptor that it is meant to be (where the dup2() branch is not taken), the end of the pipe is still closed by close(reading) even though it shouldn't be. Thanks Ted! --- libc/stdio/popen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libc/stdio') diff --git a/libc/stdio/popen.c b/libc/stdio/popen.c index cddc9d6c4..a77a82e66 100644 --- a/libc/stdio/popen.c +++ b/libc/stdio/popen.c @@ -34,8 +34,8 @@ FILE *popen (const char *command, const char *mode) if ((fp = fdopen(pnr, mode)) != NULL) { if ((pid = vfork()) == 0) { /* vfork -- child */ close(pnr); - close(reading); if (pr != reading) { + close(reading); dup2(pr, reading); close(pr); } -- cgit v1.2.3