diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/gen/popen.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/libc/gen/popen.c b/lib/libc/gen/popen.c index d7ea414..8616671 100644 --- a/lib/libc/gen/popen.c +++ b/lib/libc/gen/popen.c @@ -49,6 +49,8 @@ static char sccsid[] = "@(#)popen.c 8.3 (Berkeley) 5/3/95"; #include <string.h> #include <paths.h> +extern char **environ; + static struct pid { struct pid *next; FILE *fp; @@ -62,6 +64,7 @@ popen(command, type) struct pid *cur; FILE *iop; int pdes[2], pid, twoway; + char *argv[4]; /* * Lite2 introduced two-way popen() pipes using socketpair(). @@ -84,7 +87,12 @@ popen(command, type) return (NULL); } - switch (pid = fork()) { + argv[0] = "sh"; + argv[1] = "-c"; + argv[2] = (char *)command; + argv[3] = NULL; + + switch (pid = vfork()) { case -1: /* Error. */ (void)close(pdes[0]); (void)close(pdes[1]); @@ -116,7 +124,7 @@ popen(command, type) } (void)close(pdes[1]); } - execl(_PATH_BSHELL, "sh", "-c", command, NULL); + execve(_PATH_BSHELL, argv, environ); _exit(127); /* NOTREACHED */ } |