merge in our POSIX.2 changes (again)

This commit is contained in:
jtc 1994-05-09 16:28:27 +00:00
parent 7e97ccb740
commit 3cb178ff70

View File

@ -35,7 +35,8 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)popen.c 8.1 (Berkeley) 6/4/93";
/* static char sccsid[] = "@(#)popen.c 8.1 (Berkeley) 6/4/93"; */
static char *rcsid = "$Id: popen.c,v 1.9 1994/05/09 16:28:27 jtc Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@ -64,8 +65,10 @@ popen(program, type)
FILE *iop;
int pdes[2], pid;
if (*type != 'r' && *type != 'w' || type[1])
if (*type != 'r' && *type != 'w' || type[1]) {
errno = EINVAL;
return (NULL);
}
if ((cur = malloc(sizeof(struct pid))) == NULL)
return (NULL);
@ -96,7 +99,7 @@ popen(program, type)
}
(void)close(pdes[1]);
}
execl(_PATH_BSHELL, "sh", "-c", program, NULL);
execl(_PATH_BSHELL, "sh", "-c", program, (char *) 0);
_exit(127);
/* NOTREACHED */
}
@ -129,8 +132,7 @@ pclose(iop)
FILE *iop;
{
register struct pid *cur, *last;
int omask;
union wait pstat;
int pstat;
pid_t pid;
(void)fclose(iop);
@ -142,12 +144,9 @@ pclose(iop)
if (cur == NULL)
return (-1);
/* Get the status of the process. */
omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGHUP));
do {
pid = waitpid(cur->pid, (int *) &pstat, 0);
pid = waitpid(cur->pid, &pstat, 0);
} while (pid == -1 && errno == EINTR);
(void)sigsetmask(omask);
/* Remove the entry from the linked list. */
if (last == NULL)
@ -156,5 +155,5 @@ pclose(iop)
last->next = cur->next;
free(cur);
return (pid == -1 ? -1 : pstat.w_status);
return (pid == -1 ? -1 : pstat);
}