different approach, try signal compatibility package
authorSam Leffler <sam@ucbvax.Berkeley.EDU>
Sun, 12 Jun 1983 07:50:05 +0000 (23:50 -0800)
committerSam Leffler <sam@ucbvax.Berkeley.EDU>
Sun, 12 Jun 1983 07:50:05 +0000 (23:50 -0800)
SCCS-vsn: bin/csh/Makefile 4.3
SCCS-vsn: bin/csh/csh.c 4.12
SCCS-vsn: bin/csh/exec.c 4.7
SCCS-vsn: bin/csh/func.c 4.10
SCCS-vsn: bin/csh/csh.h 4.9
SCCS-vsn: bin/csh/hist.c 4.6
SCCS-vsn: bin/csh/proc.c 4.10
SCCS-vsn: bin/csh/sem.c 4.3

usr/src/bin/csh/Makefile
usr/src/bin/csh/csh.c
usr/src/bin/csh/csh.h
usr/src/bin/csh/exec.c
usr/src/bin/csh/func.c
usr/src/bin/csh/hist.c
usr/src/bin/csh/proc.c
usr/src/bin/csh/sem.c

index b23c514..2d226b7 100644 (file)
@@ -1,5 +1,5 @@
 #
 #
-#      Makefile        4.2     %G%
+#      Makefile        4.3     %G%
 #
 # C Shell with process control; VM/UNIX VAX Makefile
 # Bill Joy UC Berkeley; Jim Kulp IIASA, Austria
 #
 # C Shell with process control; VM/UNIX VAX Makefile
 # Bill Joy UC Berkeley; Jim Kulp IIASA, Austria
@@ -16,10 +16,10 @@ LIBES=
 SCCS=  /usr/local/sccs
 
 # strings.o must be last in OBJS since it can change when previous files compile
 SCCS=  /usr/local/sccs
 
 # strings.o must be last in OBJS since it can change when previous files compile
-OBJS=  sh.o sh.dol.o sh.err.o sh.exec.o sh.exp.o sh.func.o sh.glob.o \
-       sh.hist.o sh.lex.o sh.misc.o sh.parse.o sh.print.o sh.sem.o sh.set.o \
-       sh.proc.o sh.dir.o sh.time.o alloc.o sh.init.o printf.o \
-       strings.o doprnt.o
+OBJS=  alloc.o doprnt.o printf.o sh.o sh.dir.o sh.dol.o sh.err.o sh.exec.o \
+       sh.exp.o sh.func.o sh.glob.o sh.hist.o sh.init.o sh.lex.o sh.misc.o \
+       sh.parse.o sh.print.o sh.proc.o sh.sem.o sh.set.o sh.sig.o sh.time.o \
+       strings.o
 
 # Special massaging of C files for sharing of strings
 .c.o:
 
 # Special massaging of C files for sharing of strings
 .c.o:
@@ -89,7 +89,7 @@ install: csh sh.local.h
        install -s csh ${DESTDIR}/bin/csh
 
 clean:
        install -s csh ${DESTDIR}/bin/csh
 
 clean:
-       ${RM} -f a.out strings x.c xs.c csh
+       ${RM} -f a.out strings x.c xs.c csh errs
        ${RM} -f *.o sh.prof.c
 
 tags:  /tmp
        ${RM} -f *.o sh.prof.c
 
 tags:  /tmp
index 660bd36..0fc95ac 100644 (file)
@@ -1,4 +1,4 @@
-static char *sccsid = "@(#)csh.c 4.11 %G%";
+static char *sccsid = "@(#)csh.c 4.12 %G%";
 
 #include "sh.h"
 #include <sys/ioctl.h>
 
 #include "sh.h"
 #include <sys/ioctl.h>
@@ -111,7 +111,7 @@ main(c, av)
         * We catch it only if we are the login shell.
         */
        parintr = signal(SIGINT, SIG_IGN);      /* parents interruptibility */
         * We catch it only if we are the login shell.
         */
        parintr = signal(SIGINT, SIG_IGN);      /* parents interruptibility */
-       signal(SIGINT, parintr);                        /* ... restore */
+       sigset(SIGINT, parintr);                        /* ... restore */
        parterm = signal(SIGTERM, SIG_IGN);     /* parents terminability */
        signal(SIGTERM, parterm);                       /* ... restore */
        if (loginsh) {
        parterm = signal(SIGTERM, SIG_IGN);     /* parents terminability */
        signal(SIGTERM, parterm);                       /* ... restore */
        if (loginsh) {
@@ -258,8 +258,8 @@ main(c, av)
                **av = '-';
                if (!quitit)            /* Wary! */
                        signal(SIGQUIT, SIG_IGN);
                **av = '-';
                if (!quitit)            /* Wary! */
                        signal(SIGQUIT, SIG_IGN);
-               sigblock(mask(SIGINT));
-               signal(SIGINT, pintr);
+               sigset(SIGINT, pintr);
+               sighold(SIGINT);
                signal(SIGTERM, SIG_IGN);
                if (quitit == 0 && arginp == 0) {
                        signal(SIGTSTP, SIG_IGN);
                signal(SIGTERM, SIG_IGN);
                if (quitit == 0 && arginp == 0) {
                        signal(SIGTSTP, SIG_IGN);
@@ -283,9 +283,9 @@ retry:
                        if (ioctl(f, TIOCGPGRP, &tpgrp) == 0 && tpgrp != -1) {
                                int ldisc;
                                if (tpgrp != shpgrp) {
                        if (ioctl(f, TIOCGPGRP, &tpgrp) == 0 && tpgrp != -1) {
                                int ldisc;
                                if (tpgrp != shpgrp) {
-                                       int (*old)() = signal(SIGTTIN, SIG_DFL);
+                                       int (*old)() = sigsys(SIGTTIN, SIG_DFL);
                                        kill(0, SIGTTIN);
                                        kill(0, SIGTTIN);
-                                       signal(SIGTTIN, old);
+                                       sigsys(SIGTTIN, old);
                                        goto retry;
                                }
                                if (ioctl(f, TIOCGETD, &oldisc) != 0) 
                                        goto retry;
                                }
                                if (ioctl(f, TIOCGETD, &oldisc) != 0) 
@@ -314,7 +314,7 @@ notty:
        }
        if (setintr == 0 && parintr == SIG_DFL)
                setintr++;
        }
        if (setintr == 0 && parintr == SIG_DFL)
                setintr++;
-       signal(SIGCHLD, pchild);                /* while signals not ready */
+       sigset(SIGCHLD, pchild);                /* while signals not ready */
 
        /*
         * Set an exit here in case of an interrupt or error reading
 
        /*
         * Set an exit here in case of an interrupt or error reading
@@ -488,7 +488,7 @@ srcunit(unit, onlyown, hflg)
        getexit(oldexit);
        reenter = 0;
        if (setintr)
        getexit(oldexit);
        reenter = 0;
        if (setintr)
-               (void) sigblock(mask(SIGINT));
+               sighold(SIGINT);
        setexit();
        reenter++;
        if (reenter == 1) {
        setexit();
        reenter++;
        if (reenter == 1) {
@@ -507,14 +507,14 @@ srcunit(unit, onlyown, hflg)
                 * we let ourselves be interrupted.
                 */
                if (setintr)
                 * we let ourselves be interrupted.
                 */
                if (setintr)
-                       (void) sigrelse(mask(SIGINT));
+                       sigrelse(SIGINT);
 #ifdef TELL
                settell();
 #endif
                process(0);             /* 0 -> blow away on errors */
        }
        if (setintr)
 #ifdef TELL
                settell();
 #endif
                process(0);             /* 0 -> blow away on errors */
        }
        if (setintr)
-               (void) sigrelse(mask(SIGINT));
+               sigrelse(SIGINT);
        if (oSHIN >= 0) {
                register int i;
 
        if (oSHIN >= 0) {
                register int i;
 
@@ -578,7 +578,7 @@ goodbye()
 {
        if (loginsh) {
                signal(SIGQUIT, SIG_IGN);
 {
        if (loginsh) {
                signal(SIGQUIT, SIG_IGN);
-               signal(SIGINT, SIG_IGN);
+               sigset(SIGINT, SIG_IGN);
                signal(SIGTERM, SIG_IGN);
                setintr = 0;            /* No interrupts after "logout" */
                if (adrof("home"))
                signal(SIGTERM, SIG_IGN);
                setintr = 0;            /* No interrupts after "logout" */
                if (adrof("home"))
@@ -628,7 +628,7 @@ pintr1(wantnl)
        register char **v;
 
        if (setintr) {
        register char **v;
 
        if (setintr) {
-               (void) sigrelse(mask(SIGINT));
+               sigrelse(SIGINT);
                if (pjobs) {
                        pjobs = 0;
                        printf("\n");
                if (pjobs) {
                        pjobs = 0;
                        printf("\n");
@@ -637,8 +637,8 @@ pintr1(wantnl)
                }
        }
        if (setintr)
                }
        }
        if (setintr)
-               sigblock(mask(SIGINT));
-       sigrelse(mask(SIGCHLD));
+               sighold(SIGINT);
+       sigrelse(SIGCHLD);
        draino();
 
        /*
        draino();
 
        /*
@@ -693,7 +693,7 @@ process(catch)
                 * Interruptible during interactive reads
                 */
                if (setintr)
                 * Interruptible during interactive reads
                 */
                if (setintr)
-                       (void) sigrelse(mask(SIGINT));
+                       sigrelse(SIGINT);
 
                /*
                 * For the sake of reset()
 
                /*
                 * For the sake of reset()
@@ -771,7 +771,7 @@ process(catch)
                 * The parser may lose space if interrupted.
                 */
                if (setintr)
                 * The parser may lose space if interrupted.
                 */
                if (setintr)
-                       sigblock(mask(SIGINT));
+                       sighold(SIGINT);
 
                /*
                 * Save input text on the history list if 
 
                /*
                 * Save input text on the history list if 
index 5cf79bd..ae02fde 100644 (file)
@@ -1,4 +1,4 @@
-/* csh.h 4.8 83/06/11 */
+/* csh.h 4.9 83/06/11 */
 
 #include "sh.local.h"
 #include <time.h>
 
 #include "sh.local.h"
 #include <time.h>
 typedef        char    bool;
 
 #define        eq(a, b)        (strcmp(a, b) == 0)
 typedef        char    bool;
 
 #define        eq(a, b)        (strcmp(a, b) == 0)
+
+/*
+ * For 4.2bsd signals.
+ */
 #define        mask(s)         (1 << ((s)-1))
 #define        mask(s)         (1 << ((s)-1))
+#define        sigsys(s, a)    signal(s, a)
+#define        sighold(s)      sigblock(mask(s))
 
 /*
  * Global flags
 
 /*
  * Global flags
index f618920..560006e 100644 (file)
@@ -1,4 +1,4 @@
-static char *sccsid = "@(#)exec.c 4.6 %G%";
+static char *sccsid = "@(#)exec.c 4.7 %G%";
 
 #include "sh.h"
 #include <dir.h>
 
 #include "sh.h"
 #include <dir.h>
@@ -93,8 +93,10 @@ doexec(t)
         * We must do this AFTER any possible forking (like `foo`
         * in glob) so that this shell can still do subprocesses.
         */
         * We must do this AFTER any possible forking (like `foo`
         * in glob) so that this shell can still do subprocesses.
         */
-       signal(SIGCHLD, SIG_IGN);
-       sigsetmask(0);                  /* sanity */
+#ifdef notdef
+       sigsys(SIGCHLD, SIG_IGN);       /* sigsys for vforks sake */
+#endif
+       sigsetmask(0);
 
        /*
         * If no path, no words in path, or a / in the filename
 
        /*
         * If no path, no words in path, or a / in the filename
index 7f9f8a6..15b16af 100644 (file)
@@ -1,4 +1,4 @@
-static char *sccsid = "@(#)func.c 4.9 83/06/10";
+static char *sccsid = "@(#)func.c 4.10 83/06/11";
 
 #include "sh.h"
 #include <sys/ioctl.h>
 
 #include "sh.h"
 #include <sys/ioctl.h>
@@ -75,16 +75,16 @@ doonintr(v)
        cp = gointr, gointr = 0, xfree(cp);
        if (vv == 0) {
                if (setintr)
        cp = gointr, gointr = 0, xfree(cp);
        if (vv == 0) {
                if (setintr)
-                       (void) sigblock(mask(SIGINT));
+                       sighold(SIGINT);
                else
                else
-                       signal(SIGINT, SIG_DFL);
+                       sigset(SIGINT, SIG_DFL);
                gointr = 0;
        } else if (eq((vv = strip(vv)), "-")) {
                gointr = 0;
        } else if (eq((vv = strip(vv)), "-")) {
-               signal(SIGINT, SIG_IGN);
+               sigset(SIGINT, SIG_IGN);
                gointr = "-";
        } else {
                gointr = savestr(vv);
                gointr = "-";
        } else {
                gointr = savestr(vv);
-               signal(SIGINT, pintr);
+               sigset(SIGINT, pintr);
        }
 }
 
        }
 }
 
@@ -400,10 +400,10 @@ preread()
 
        whyles->w_end = -1;
        if (setintr)
 
        whyles->w_end = -1;
        if (setintr)
-               (void) sigrelse(mask(SIGINT));
+               sigrelse(SIGINT);
        search(ZBREAK, 0);
        if (setintr)
        search(ZBREAK, 0);
        if (setintr)
-               sigblock(mask(SIGINT));
+               sighold(SIGINT);
        whyles->w_end = btell();
 }
 
        whyles->w_end = btell();
 }
 
@@ -453,17 +453,17 @@ dorepeat(v, kp)
 
        i = getn(v[1]);
        if (setintr)
 
        i = getn(v[1]);
        if (setintr)
-               (void) sigblock(mask(SIGINT));
+               sighold(SIGINT);
        lshift(v, 2);
        while (i > 0) {
                if (setintr)
        lshift(v, 2);
        while (i > 0) {
                if (setintr)
-                       (void) sigrelse(mask(SIGINT));
+                       sigrelse(SIGINT);
                reexecute(kp);
                --i;
        }
        donefds();
        if (setintr)
                reexecute(kp);
                --i;
        }
        donefds();
        if (setintr)
-               (void) sigrelse(mask(SIGINT));
+               sigrelse(SIGINT);
 }
 
 doswbrk()
 }
 
 doswbrk()
@@ -699,7 +699,7 @@ echo(sep, v)
        int nonl = 0;
 
        if (setintr)
        int nonl = 0;
 
        if (setintr)
-               (void) sigrelse(mask(SIGINT));
+               sigrelse(SIGINT);
        v++;
        if (*v == 0)
                return;
        v++;
        if (*v == 0)
                return;
@@ -725,7 +725,7 @@ echo(sep, v)
        else
                flush();
        if (setintr)
        else
                flush();
        if (setintr)
-               (void) sigblock(mask(SIGINT));
+               sighold(SIGINT);
        if (gargv)
                blkfree(gargv), gargv = 0;
 }
        if (gargv)
                blkfree(gargv), gargv = 0;
 }
@@ -1008,17 +1008,17 @@ dosuspend()
        if (loginsh)
                error("Can't suspend a login shell (yet)");
        untty();
        if (loginsh)
                error("Can't suspend a login shell (yet)");
        untty();
-       old = signal(SIGTSTP, SIG_DFL);
+       old = sigsys(SIGTSTP, SIG_DFL);
        kill(0, SIGTSTP);
        /* the shell stops here */
        kill(0, SIGTSTP);
        /* the shell stops here */
-       signal(SIGTSTP, old);
+       sigsys(SIGTSTP, old);
        if (tpgrp != -1) {
 retry:
                ioctl(FSHTTY, TIOCGPGRP, &ctpgrp);
                if (ctpgrp != opgrp) {
        if (tpgrp != -1) {
 retry:
                ioctl(FSHTTY, TIOCGPGRP, &ctpgrp);
                if (ctpgrp != opgrp) {
-                       old = signal(SIGTTIN, SIG_DFL);
+                       old = sigsys(SIGTTIN, SIG_DFL);
                        kill(0, SIGTTIN);
                        kill(0, SIGTTIN);
-                       signal(SIGTTIN, old);
+                       sigsys(SIGTTIN, old);
                        goto retry;
                }
                ioctl(FSHTTY, TIOCSPGRP, &shpgrp);
                        goto retry;
                }
                ioctl(FSHTTY, TIOCSPGRP, &shpgrp);
index 774e1cc..64ed6ae 100644 (file)
@@ -1,4 +1,4 @@
-static char *sccsid = "@(#)hist.c 4.5 %G%";
+static char *sccsid = "@(#)hist.c 4.6 %G%";
 
 #include "sh.h"
 
 
 #include "sh.h"
 
@@ -73,7 +73,7 @@ dohist(vp)
        if (getn(value("history")) == 0)
                return;
        if (setintr)
        if (getn(value("history")) == 0)
                return;
        if (setintr)
-               (void) sigrelse(mask(SIGINT));
+               sigrelse(SIGINT);
        vp++;
        while (*vp && *vp[0] == '-') {
                if (*vp && eq(*vp, "-h")) {
        vp++;
        while (*vp && *vp[0] == '-') {
                if (*vp && eq(*vp, "-h")) {
index 8a64ea1..3ad725f 100644 (file)
@@ -1,4 +1,4 @@
-static char *sccsid = "@(#)proc.c      4.9 (Berkeley) 83/06/10";
+static char *sccsid = "@(#)proc.c      4.10 (Berkeley) 83/06/11";
 
 #include "sh.h"
 #include "sh.dir.h"
 
 #include "sh.h"
 #include "sh.dir.h"
@@ -144,12 +144,12 @@ pnote()
        neednote = 0;
        for (pp = proclist.p_next; pp != PNULL; pp = pp->p_next) {
                if (pp->p_flags & PNEEDNOTE) {
        neednote = 0;
        for (pp = proclist.p_next; pp != PNULL; pp = pp->p_next) {
                if (pp->p_flags & PNEEDNOTE) {
-                       (void) sigblock(mask(SIGCHLD));
+                       sighold(SIGCHLD);
                        pp->p_flags &= ~PNEEDNOTE;
                        flags = pprint(pp, NUMBER|NAME|REASON);
                        if ((flags&(PRUNNING|PSTOPPED)) == 0)
                                pflush(pp);
                        pp->p_flags &= ~PNEEDNOTE;
                        flags = pprint(pp, NUMBER|NAME|REASON);
                        if ((flags&(PRUNNING|PSTOPPED)) == 0)
                                pflush(pp);
-                       (void) sigrelse(mask(SIGCHLD));
+                       sigrelse(SIGCHLD);
                }
        }
 }
                }
        }
 }
@@ -165,7 +165,7 @@ pwait()
        /*
         * Here's where dead procs get flushed.
         */
        /*
         * Here's where dead procs get flushed.
         */
-       (void) sigblock(mask(SIGCHLD));
+       sighold(SIGCHLD);
        for (pp = (fp = &proclist)->p_next; pp != PNULL; pp = (fp = pp)->p_next)
                if (pp->p_pid == 0) {
                        fp->p_next = pp->p_next;
        for (pp = (fp = &proclist)->p_next; pp != PNULL; pp = (fp = pp)->p_next)
                if (pp->p_pid == 0) {
                        fp->p_next = pp->p_next;
@@ -176,11 +176,9 @@ pwait()
                        xfree((char *)pp);
                        pp = fp;
                }
                        xfree((char *)pp);
                        pp = fp;
                }
-       (void) sigrelse(mask(SIGCHLD));
-#ifdef notdef
+       sigrelse(SIGCHLD);
        if (setintr)
        if (setintr)
-               signal(SIGINT, SIG_IGN);
-#endif
+               sigignore(SIGINT);
        pjwait(pcurrjob);
 }
 
        pjwait(pcurrjob);
 }
 
@@ -192,7 +190,7 @@ pjwait(pp)
        register struct process *pp;
 {
        register struct process *fp;
        register struct process *pp;
 {
        register struct process *fp;
-       int jobflags, reason, omask;
+       int jobflags, reason;
 
        fp = pp;
        do {
 
        fp = pp;
        do {
@@ -204,17 +202,17 @@ pjwait(pp)
         * and the target process, or any of its friends, are running
         */
        fp = pp;
         * and the target process, or any of its friends, are running
         */
        fp = pp;
-       omask = sigblock(mask(SIGCHLD));
        for (;;) {
        for (;;) {
+               sighold(SIGCHLD);
                jobflags = 0;
                do
                        jobflags |= fp->p_flags;
                while((fp = (fp->p_friends)) != pp);
                if ((jobflags & PRUNNING) == 0)
                        break;
                jobflags = 0;
                do
                        jobflags |= fp->p_flags;
                while((fp = (fp->p_friends)) != pp);
                if ((jobflags & PRUNNING) == 0)
                        break;
-               sigpause(omask &~ mask(SIGCHLD));
+               sigpause(sigblock(0) &~ mask(SIGCHLD));
        }
        }
-       sigsetmask(omask);
+       sigrelse(SIGCHLD);
        if (tpgrp > 0)
                ioctl(FSHTTY, TIOCSPGRP, &tpgrp);       /* get tty back */
        if ((jobflags&(PSIGNALED|PSTOPPED|PTIME)) ||
        if (tpgrp > 0)
                ioctl(FSHTTY, TIOCSPGRP, &tpgrp);       /* get tty back */
        if ((jobflags&(PSIGNALED|PSTOPPED|PTIME)) ||
@@ -249,20 +247,19 @@ pjwait(pp)
 dowait()
 {
        register struct process *pp;
 dowait()
 {
        register struct process *pp;
-       int omask;
 
        pjobs++;
        if (setintr)
 
        pjobs++;
        if (setintr)
-               (void) sigrelse(mask(SIGINT));
-       omask = sigblock(mask(SIGCHLD));
+               sigrelse(SIGINT);
 loop:
 loop:
+       sighold(SIGCHLD);
        for (pp = proclist.p_next; pp; pp = pp->p_next)
                if (pp->p_pid && pp->p_pid == pp->p_jobid &&
                    pp->p_flags&PRUNNING) {
        for (pp = proclist.p_next; pp; pp = pp->p_next)
                if (pp->p_pid && pp->p_pid == pp->p_jobid &&
                    pp->p_flags&PRUNNING) {
-                       sigpause(omask &~ mask(SIGCHLD));
+                       sigpause(sigblock(0) &~ mask(SIGCHLD));
                        goto loop;
                }
                        goto loop;
                }
-       sigsetmask(omask);
+       sigrelse(SIGCHLD);
        pjobs = 0;
 }
 
        pjobs = 0;
 }
 
@@ -707,7 +704,7 @@ dofg(v)
                pp = pfind(*v);
                pstart(pp, 1);
                if (setintr)
                pp = pfind(*v);
                pstart(pp, 1);
                if (setintr)
-                       signal(SIGINT, SIG_IGN);
+                       sigignore(SIGINT);
                pjwait(pp);
        } while (*v && *++v);
 }
                pjwait(pp);
        } while (*v && *++v);
 }
@@ -724,7 +721,7 @@ dofg1(v)
        pp = pfind(v[0]);
        pstart(pp, 1);
        if (setintr)
        pp = pfind(v[0]);
        pstart(pp, 1);
        if (setintr)
-               signal(SIGINT, SIG_IGN);
+               sigignore(SIGINT);
        pjwait(pp);
 }
 
        pjwait(pp);
 }
 
@@ -815,12 +812,11 @@ pkill(v, signum)
        register int jobflags = 0;
        int pid;
        extern char *sys_errlist[];
        register int jobflags = 0;
        int pid;
        extern char *sys_errlist[];
-       int err = 0, omask = 0;
+       int err = 0;
 
        if (setintr)
 
        if (setintr)
-               omask |= mask(SIGINT);
-       omask |= mask(SIGCHLD);
-       omask = sigblock(omask);
+               sighold(SIGINT);
+       sighold(SIGCHLD);
        while (*v) {
                if (**v == '%') {
                        np = pp = pfind(*v);
        while (*v) {
                if (**v == '%') {
                        np = pp = pfind(*v);
@@ -858,7 +854,9 @@ pkill(v, signum)
 cont:
                v++;
        }
 cont:
                v++;
        }
-       sigsetmask(omask);
+       sigrelse(SIGCHLD);
+       if (setintr)
+               sigrelse(SIGINT);
        if (err)
                error(NOSTR);
 }
        if (err)
                error(NOSTR);
 }
@@ -873,7 +871,7 @@ pstart(pp, foregnd)
        register struct process *np;
        int jobflags = 0;
 
        register struct process *np;
        int jobflags = 0;
 
-       (void) sigblock(mask(SIGCHLD));
+       sighold(SIGCHLD);
        np = pp;
        do {
                jobflags |= np->p_flags;
        np = pp;
        do {
                jobflags |= np->p_flags;
@@ -893,7 +891,7 @@ pstart(pp, foregnd)
                ioctl(FSHTTY, TIOCSPGRP, &pp->p_jobid);
        if (jobflags&PSTOPPED)
                killpg(pp->p_jobid, SIGCONT);
                ioctl(FSHTTY, TIOCSPGRP, &pp->p_jobid);
        if (jobflags&PSTOPPED)
                killpg(pp->p_jobid, SIGCONT);
-       (void) sigrelse(mask(SIGCHLD));
+       sigrelse(SIGCHLD);
 }
 
 panystop(neednl)
 }
 
 panystop(neednl)
@@ -1005,7 +1003,7 @@ pfork(t, wanttty)
 {
        register int pid;
        bool ignint = 0;
 {
        register int pid;
        bool ignint = 0;
-       int pgrp, omask;
+       int pgrp;
 
        /*
         * A child will be uninterruptible only under very special
 
        /*
         * A child will be uninterruptible only under very special
@@ -1022,12 +1020,13 @@ pfork(t, wanttty)
        /*
         * Hold SIGCHLD until we have the process installed in our table.
         */
        /*
         * Hold SIGCHLD until we have the process installed in our table.
         */
-       (void) sigblock(mask(SIGCHLD));
+       sighold(SIGCHLD);
        while ((pid = fork()) < 0)
                if (setintr == 0)
                        sleep(FORKSLEEP);
                else {
        while ((pid = fork()) < 0)
                if (setintr == 0)
                        sleep(FORKSLEEP);
                else {
-                       (void) sigrelse(mask(SIGINT)|mask(SIGCHLD));
+                       sigrelse(SIGINT);
+                       sigrelse(SIGCHLD);
                        error("No more processes");
                }
        if (pid == 0) {
                        error("No more processes");
                }
        if (pid == 0) {
@@ -1039,7 +1038,7 @@ pfork(t, wanttty)
                child++;
                if (setintr) {
                        setintr = 0;            /* until I think otherwise */
                child++;
                if (setintr) {
                        setintr = 0;            /* until I think otherwise */
-                       (void) sigrelse(mask(SIGCHLD));
+                       sigrelse(SIGCHLD);
                        /*
                         * Children just get blown away on SIGINT, SIGQUIT
                         * unless "onintr -" seen.
                        /*
                         * Children just get blown away on SIGINT, SIGQUIT
                         * unless "onintr -" seen.
@@ -1077,11 +1076,10 @@ pfork(t, wanttty)
 */
                        nice(t->t_nice);
                }
 */
                        nice(t->t_nice);
                }
-               sigrelse(mask(SIGINT));
 
        } else {
                palloc(pid, t);
 
        } else {
                palloc(pid, t);
-               (void) sigrelse(mask(SIGCHLD));
+               sigrelse(SIGCHLD);
        }
 
        return (pid);
        }
 
        return (pid);
@@ -1095,12 +1093,3 @@ okpcntl()
        if (tpgrp == 0)
                error("No job control in subshells");
 }
        if (tpgrp == 0)
                error("No job control in subshells");
 }
-
-/*
- * For "compatibility".
- */
-sigrelse(m)
-{
-
-       return (sigsetmask(sigblock(0) &~ m));
-}
index 08b88cb..53b77f2 100644 (file)
@@ -1,4 +1,4 @@
-static char *sccsid = "@(#)sem.c 4.2 %G%";
+static char *sccsid = "@(#)sem.c 4.3 %G%";
 
 #include "sh.h"
 #include "sh.proc.h"
 
 #include "sh.h"
 #include "sh.proc.h"
@@ -114,7 +114,7 @@ execute(t, wanttty, pipein, pipeout)
                        int ochild, osetintr, ohaderr, odidfds, odidcch;
                        int oSHIN, oSHOUT, oSHDIAG, oOLDSTD, otpgrp;
 
                        int ochild, osetintr, ohaderr, odidfds, odidcch;
                        int oSHIN, oSHOUT, oSHDIAG, oOLDSTD, otpgrp;
 
-                       (void) sigblock(mask(SIGCHLD));
+                       sighold(SIGCHLD);
                        ochild = child; osetintr = setintr;
                        ohaderr = haderr; odidfds = didfds; odidcch = didcch;
                        oSHIN = SHIN; oSHOUT = SHOUT;
                        ochild = child; osetintr = setintr;
                        ohaderr = haderr; odidfds = didfds; odidcch = didcch;
                        oSHIN = SHIN; oSHOUT = SHOUT;
@@ -122,7 +122,7 @@ execute(t, wanttty, pipein, pipeout)
                        Vsav = Vdp = 0; Vav = 0;
                        pid = vfork();
                        if (pid < 0) {
                        Vsav = Vdp = 0; Vav = 0;
                        pid = vfork();
                        if (pid < 0) {
-                               (void) sigrelse(mask(SIGCHLD));
+                               sigrelse(SIGCHLD);
                                error("No more processes");
                        }
                        forked++;
                                error("No more processes");
                        }
                        forked++;
@@ -137,7 +137,7 @@ execute(t, wanttty, pipein, pipeout)
                                xfree(Vav); Vav = 0;
                                /* this is from pfork() */
                                palloc(pid, t);
                                xfree(Vav); Vav = 0;
                                /* this is from pfork() */
                                palloc(pid, t);
-                               (void) sigrelse(mask(SIGCHLD));
+                               sigrelse(SIGCHLD);
                        } else {
                                /* this is from pfork() */
                                int pgrp;
                        } else {
                                /* this is from pfork() */
                                int pgrp;
@@ -152,21 +152,21 @@ execute(t, wanttty, pipein, pipeout)
                                if (setintr) {
                                        setintr = 0;
 #ifdef notdef
                                if (setintr) {
                                        setintr = 0;
 #ifdef notdef
-                                       signal(SIGCHLD, SIG_DFL);
+                                       sigsys(SIGCHLD, SIG_DFL);
 #endif
 #endif
-                                       signal(SIGINT,
+                                       sigsys(SIGINT,
                                            ignint ? SIG_IGN : vffree);
                                            ignint ? SIG_IGN : vffree);
-                                       signal(SIGQUIT,
+                                       sigsys(SIGQUIT,
                                            ignint ? SIG_IGN : SIG_DFL);
                                        if (wanttty >= 0) {
                                            ignint ? SIG_IGN : SIG_DFL);
                                        if (wanttty >= 0) {
-                                               signal(SIGTSTP, SIG_DFL);
-                                               signal(SIGTTIN, SIG_DFL);
-                                               signal(SIGTTOU, SIG_DFL);
+                                               sigsys(SIGTSTP, SIG_DFL);
+                                               sigsys(SIGTTIN, SIG_DFL);
+                                               sigsys(SIGTTOU, SIG_DFL);
                                        }
                                        }
-                                       signal(SIGTERM, parterm);
+                                       sigsys(SIGTERM, parterm);
                                } else if (tpgrp == -1 && (t->t_dflg&FINT)) {
                                } else if (tpgrp == -1 && (t->t_dflg&FINT)) {
-                                       signal(SIGINT, SIG_IGN);
-                                       signal(SIGQUIT, SIG_IGN);
+                                       sigsys(SIGINT, SIG_IGN);
+                                       sigsys(SIGQUIT, SIG_IGN);
                                }
                                if (wanttty > 0)
                                        ioctl(FSHTTY, TIOCSPGRP, &pgrp);
                                }
                                if (wanttty > 0)
                                        ioctl(FSHTTY, TIOCSPGRP, &pgrp);
@@ -175,7 +175,7 @@ execute(t, wanttty, pipein, pipeout)
                                if (tpgrp > 0)
                                        tpgrp = 0;
                                if (t->t_dflg & FNOHUP)
                                if (tpgrp > 0)
                                        tpgrp = 0;
                                if (t->t_dflg & FNOHUP)
-                                       signal(SIGHUP, SIG_IGN);
+                                       sigsys(SIGHUP, SIG_IGN);
                                if (t->t_dflg & FNICE)
                                        nice(t->t_nice);
                        }
                                if (t->t_dflg & FNICE)
                                        nice(t->t_nice);
                        }