1 --- popen.c.orig Mon May 24 23:50:41 2004
2 +++ popen.c Tue May 25 00:09:39 2004
7 +#include <sys/socket.h>
12 #include "un-namespace.h"
13 #include "libc_private.h"
15 -extern char **environ;
16 +#include <crt_externs.h>
17 +#define environ (*_NSGetEnviron())
19 +/* 3516149 - store file descriptor and use that to close to prevent blocking */
26 static pthread_mutex_t pidlist_mutex = PTHREAD_MUTEX_INITIALIZER;
32 - * Lite2 introduced two-way popen() pipes using _socketpair().
33 - * FreeBSD's pipe() is bidirectional, so we use that.
35 if (strchr(type, '+')) {
38 + if (socketpair(AF_UNIX, SOCK_STREAM, 0, pdes) < 0)
42 if ((*type != 'r' && *type != 'w') || type[1])
50 if ((cur = malloc(sizeof(struct pid))) == NULL) {
51 (void)_close(pdes[0]);
53 (void)_close(pdes[1]);
55 for (p = pidlist; p; p = p->next) {
56 - (void)_close(fileno(p->fp));
57 + (void)_close(p->fd);
59 _execve(_PATH_BSHELL, argv, environ);
62 /* Parent; assume fdopen can't fail. */
64 iop = fdopen(pdes[0], type);
66 (void)_close(pdes[1]);
68 iop = fdopen(pdes[1], type);
70 (void)_close(pdes[0]);