BSD 4_3_Tahoe release
[unix-history] / usr / src / ucb / Mail / popen.c
index d58ff86..a9a0c1a 100644 (file)
@@ -1,28 +1,30 @@
 /*
  * Copyright (c) 1980 Regents of the University of California.
 /*
  * 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 <stdio.h>
-#include <signal.h>
+#include <sys/signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
 #include <errno.h>
 #include <errno.h>
+
 #define        tst(a,b)        (*mode == 'r'? (b) : (a))
 #define        RDR     0
 #define        WTR     1
 static int     popen_pid[20];
 
 #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;
 FILE *
 popen(cmd,mode)
 char   *cmd;
@@ -37,7 +39,6 @@ char  *mode;
        hisside = tst(p[RDR], p[WTR]);
        if((pid = vfork()) == 0) {
                /* myside and hisside reverse roles in child */
        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);
                close(myside);
                dup2(hisside, tst(0, 1));
                close(hisside);
@@ -55,20 +56,17 @@ pclose(ptr)
 FILE *ptr;
 {
        register f, r;
 FILE *ptr;
 {
        register f, r;
-       int status, omask;
+       int omask;
+       union wait status;
        extern int errno;
 
        f = fileno(ptr);
        fclose(ptr);
        extern int errno;
 
        f = fileno(ptr);
        fclose(ptr);
-# ifdef VMUNIX
        omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGHUP));
        omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGHUP));
-# endif VMUNIX
        while((r = wait(&status)) != popen_pid[f] && r != -1 && errno != EINTR)
                ;
        if(r == -1)
        while((r = wait(&status)) != popen_pid[f] && r != -1 && errno != EINTR)
                ;
        if(r == -1)
-               status = -1;
-# ifdef VMUNIX
+               status.w_status = -1;
        sigsetmask(omask);
        sigsetmask(omask);
-# endif VMUNIX
-       return(status);
+       return (status.w_status);
 }
 }