diff options
author | bde <bde@FreeBSD.org> | 1997-03-11 18:51:43 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1997-03-11 18:51:43 +0000 |
commit | 89013b759d296f0f99e532978864d5646f737ae2 (patch) | |
tree | 70020226e462c4c5c17c0fd92f1fa918218c1c5f /lib/libc/gen/popen.c | |
parent | c555acba17ea242af9d4a85d4e2f7dbcee6515e6 (diff) | |
download | FreeBSD-src-89013b759d296f0f99e532978864d5646f737ae2.zip FreeBSD-src-89013b759d296f0f99e532978864d5646f737ae2.tar.gz |
Fixed cleaning up after malloc failure, which was broken by Lite2.
We don't use socketpair(), so don't #include <sys/socket.h>.
Restored some gcc-quieting parentheses that were lost in the Lite2 merge.
Diffstat (limited to 'lib/libc/gen/popen.c')
-rw-r--r-- | lib/libc/gen/popen.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libc/gen/popen.c b/lib/libc/gen/popen.c index ae809f5..f76f9e5 100644 --- a/lib/libc/gen/popen.c +++ b/lib/libc/gen/popen.c @@ -40,7 +40,6 @@ static char sccsid[] = "@(#)popen.c 8.3 (Berkeley) 5/3/95"; #include <sys/param.h> #include <sys/wait.h> -#include <sys/socket.h> #include <signal.h> #include <errno.h> @@ -73,14 +72,17 @@ popen(command, type) type = "r+"; } else { twoway = 0; - if (*type != 'r' && *type != 'w' || type[1]) + if ((*type != 'r' && *type != 'w') || type[1]) return (NULL); } if (pipe(pdes) < 0) return (NULL); - if ((cur = malloc(sizeof(struct pid))) == NULL) + if ((cur = malloc(sizeof(struct pid))) == NULL) { + (void)close(pdes[0]); + (void)close(pdes[1]); return (NULL); + } switch (pid = vfork()) { case -1: /* Error. */ |