diff options
author | Peter Wemm <peter@FreeBSD.org> | 1998-10-11 14:11:51 +0000 |
---|---|---|
committer | Peter Wemm <peter@FreeBSD.org> | 1998-10-11 14:11:51 +0000 |
commit | 0c372549f6cc3fb5753f29bbc6989c9d6ce5d165 (patch) | |
tree | ffd394536af33bef6e19d5c8f67617e8f3001c1a /lib/libc/gen/popen.c | |
parent | 13393996948bd15b4c068037d9ff8c0cf1bdd453 (diff) | |
download | src-0c372549f6cc3fb5753f29bbc6989c9d6ce5d165.tar.gz src-0c372549f6cc3fb5753f29bbc6989c9d6ce5d165.zip |
Notes
Diffstat (limited to 'lib/libc/gen/popen.c')
-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 d7ea414b0820..86166711c2bf 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 */ } |