/*
* Copyright (c) 1980 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and that due credit is given
+ * to the University of California at Berkeley. The name of the University
+ * may not be used to endorse or promote products derived from this
+ * software without specific prior written permission. This software
+ * is provided ``as is'' without express or implied warranty.
*/
-#ifndef lint
-static char *sccsid = "@(#)popen.c 5.2 (Berkeley) 6/21/85";
-#endif not lint
+#ifdef notdef
+static char sccsid[] = "@(#)popen.c 5.4 (Berkeley) 2/18/88";
+#endif /* notdef */
#include <stdio.h>
-#include <signal.h>
+#include <sys/signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
#include <errno.h>
+
#define tst(a,b) (*mode == 'r'? (b) : (a))
#define RDR 0
#define WTR 1
static int popen_pid[20];
-#ifndef VMUNIX
-#define vfork fork
-#endif VMUNIX
-#ifndef SIGRETRO
-#define sigchild()
-#endif
-
FILE *
popen(cmd,mode)
char *cmd;
hisside = tst(p[RDR], p[WTR]);
if((pid = vfork()) == 0) {
/* myside and hisside reverse roles in child */
- sigchild();
close(myside);
dup2(hisside, tst(0, 1));
close(hisside);
FILE *ptr;
{
register f, r;
- int status, omask;
+ int omask;
+ union wait status;
extern int errno;
f = fileno(ptr);
fclose(ptr);
-# ifdef VMUNIX
omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGHUP));
-# endif VMUNIX
while((r = wait(&status)) != popen_pid[f] && r != -1 && errno != EINTR)
;
if(r == -1)
- status = -1;
-# ifdef VMUNIX
+ status.w_status = -1;
sigsetmask(omask);
-# endif VMUNIX
- return(status);
+ return (status.w_status);
}