make it look like kernel driver
[unix-history] / usr / src / bin / csh / proc.c
index f11a7e6..e0c9aa5 100644 (file)
@@ -1,9 +1,17 @@
-static char *sccsid = "@(#)proc.c 4.2 %G%";
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley Software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef lint
+static char *sccsid = "@(#)proc.c      5.5 (Berkeley) %G%";
+#endif
 
 #include "sh.h"
 #include "sh.dir.h"
 #include "sh.proc.h"
 
 #include "sh.h"
 #include "sh.dir.h"
 #include "sh.proc.h"
-#include <wait.h>
+#include <sys/wait.h>
 #include <sys/ioctl.h>
 
 /*
 #include <sys/ioctl.h>
 
 /*
@@ -26,19 +34,10 @@ pchild()
        register int pid;
        union wait w;
        int jobflags;
        register int pid;
        union wait w;
        int jobflags;
-#ifdef VMUNIX
-       struct vtimes vt;
-#endif
+       struct rusage ru;
 
 
-       if (!timesdone)
-               timesdone++, times(&shtimes);
 loop:
 loop:
-       pid = wait3(&w.w_status, (setintr ? WNOHANG|WUNTRACED:WNOHANG),
-#ifndef VMUNIX
-           0);
-#else
-           &vt);
-#endif
+       pid = wait3(&w, (setintr ? WNOHANG|WUNTRACED:WNOHANG), &ru);
        if (pid <= 0) {
                if (errno == EINTR) {
                        errno = 0;
        if (pid <= 0) {
                if (errno == EINTR) {
                        errno = 0;
@@ -59,19 +58,9 @@ found:
                pp->p_flags |= PSTOPPED;
                pp->p_reason = w.w_stopsig;
        } else {
                pp->p_flags |= PSTOPPED;
                pp->p_reason = w.w_stopsig;
        } else {
-               if (pp->p_flags & (PTIME|PPTIME) || adrof("time")) {
-                       time_t oldcutimes, oldcstimes;
-                       oldcutimes = shtimes.tms_cutime;
-                       oldcstimes = shtimes.tms_cstime;
-                       time(&pp->p_etime);
-                       times(&shtimes);
-                       pp->p_utime = shtimes.tms_cutime - oldcutimes;
-                       pp->p_stime = shtimes.tms_cstime - oldcstimes;
-               } else
-                       times(&shtimes);
-#ifdef VMUNIX
-               pp->p_vtimes = vt;
-#endif
+               if (pp->p_flags & (PTIME|PPTIME) || adrof("time"))
+                       (void) gettimeofday(&pp->p_etime, (struct timezone *)0);
+               pp->p_rusage = ru;
                if (WIFSIGNALED(w)) {
                        if (w.w_termsig == SIGINT)
                                pp->p_flags |= PINTERRUPTED;
                if (WIFSIGNALED(w)) {
                        if (w.w_termsig == SIGINT)
                                pp->p_flags |= PINTERRUPTED;
@@ -82,11 +71,7 @@ found:
                        pp->p_reason = w.w_termsig;
                } else {
                        pp->p_reason = w.w_retcode;
                        pp->p_reason = w.w_termsig;
                } else {
                        pp->p_reason = w.w_retcode;
-#ifdef IIASA
-                       if (pp->p_reason >= 3)
-#else
                        if (pp->p_reason != 0)
                        if (pp->p_reason != 0)
-#endif
                                pp->p_flags |= PAEXITED;
                        else
                                pp->p_flags |= PNEXITED;
                                pp->p_flags |= PAEXITED;
                        else
                                pp->p_flags |= PNEXITED;
@@ -97,7 +82,7 @@ found:
        do {
                if ((fp->p_flags & (PPTIME|PRUNNING|PSTOPPED)) == 0 &&
                    !child && adrof("time") &&
        do {
                if ((fp->p_flags & (PPTIME|PRUNNING|PSTOPPED)) == 0 &&
                    !child && adrof("time") &&
-                   (fp->p_utime + fp->p_stime) / HZ >=
+                   fp->p_rusage.ru_utime.tv_sec+fp->p_rusage.ru_stime.tv_sec >=
                     atoi(value("time")))
                        fp->p_flags |= PTIME;
                jobflags |= fp->p_flags;
                     atoi(value("time")))
                        fp->p_flags |= PTIME;
                jobflags |= fp->p_flags;
@@ -127,15 +112,16 @@ found:
                            jobflags & PAEXITED ||
 #endif
                            !eq(dcwd->di_name, fp->p_cwd->di_name)) {
                            jobflags & PAEXITED ||
 #endif
                            !eq(dcwd->di_name, fp->p_cwd->di_name)) {
-                               if (jobflags & PSTOPPED)
-                                       printf("\n");
-                               pprint(fp, AREASON|SHELLDIR);
-                       } else if ((jobflags & (PTIME|PSTOPPED)) == PTIME)
+                               ;       /* print in pjwait */
+                       }
+/*
+               else if ((jobflags & (PTIME|PSTOPPED)) == PTIME)
                                ptprint(fp);
                                ptprint(fp);
+*/
                } else {
                        if (jobflags&PNOTIFY || adrof("notify")) {
                                printf("\215\n");
                } else {
                        if (jobflags&PNOTIFY || adrof("notify")) {
                                printf("\215\n");
-                               pprint(pp, NUMBER|NAME|REASON);
+                               (void) pprint(pp, NUMBER|NAME|REASON);
                                if ((jobflags&PSTOPPED) == 0)
                                        pflush(pp);
                        } else {
                                if ((jobflags&PSTOPPED) == 0)
                                        pflush(pp);
                        } else {
@@ -150,17 +136,17 @@ found:
 pnote()
 {
        register struct process *pp;
 pnote()
 {
        register struct process *pp;
-       int flags;
+       int flags, omask;
 
        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) {
-                       sighold(SIGCHLD);
+                       omask = sigblock(sigmask(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);
-                       sigrelse(SIGCHLD);
+                       (void) sigsetmask(omask);
                }
        }
 }
                }
        }
 }
@@ -172,11 +158,12 @@ pnote()
 pwait()
 {
        register struct process *fp, *pp;
 pwait()
 {
        register struct process *fp, *pp;
+       int omask;
 
        /*
         * Here's where dead procs get flushed.
         */
 
        /*
         * Here's where dead procs get flushed.
         */
-       sighold(SIGCHLD);
+       omask = sigblock(sigmask(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;
@@ -187,9 +174,7 @@ pwait()
                        xfree((char *)pp);
                        pp = fp;
                }
                        xfree((char *)pp);
                        pp = fp;
                }
-       sigrelse(SIGCHLD);
-       if (setintr)
-               sigignore(SIGINT);
+       (void) sigsetmask(omask);
        pjwait(pcurrjob);
 }
 
        pjwait(pcurrjob);
 }
 
@@ -201,8 +186,10 @@ pjwait(pp)
        register struct process *pp;
 {
        register struct process *fp;
        register struct process *pp;
 {
        register struct process *fp;
-       int jobflags, reason;
+       int jobflags, reason, omask;
 
 
+       while (pp->p_pid != pp->p_jobid)
+               pp = pp->p_friends;
        fp = pp;
        do {
                if ((fp->p_flags&(PFOREGND|PRUNNING)) == PRUNNING)
        fp = pp;
        do {
                if ((fp->p_flags&(PFOREGND|PRUNNING)) == PRUNNING)
@@ -213,25 +200,30 @@ 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(sigmask(SIGCHLD));
        for (;;) {
        for (;;) {
-               sighold(SIGCHLD);
                jobflags = 0;
                do
                        jobflags |= fp->p_flags;
                jobflags = 0;
                do
                        jobflags |= fp->p_flags;
-               while((fp = (fp->p_friends)) != pp);
+               while ((fp = (fp->p_friends)) != pp);
                if ((jobflags & PRUNNING) == 0)
                        break;
                if ((jobflags & PRUNNING) == 0)
                        break;
-               sigpause(SIGCHLD);
+               sigpause(sigblock(0) &~ sigmask(SIGCHLD));
        }
        }
-       sigrelse(SIGCHLD);
-       if (tpgrp > 0)
-               ioctl(FSHTTY, TIOCSPGRP, &tpgrp);       /* get tty back */
-       if (jobflags & PSTOPPED)
-               return;
-       if ((jobflags&PINTERRUPTED) && setintr &&
+       (void) sigsetmask(omask);
+       if (tpgrp > 0)                  /* get tty back */
+               (void) ioctl(FSHTTY, TIOCSPGRP, (char *)&tpgrp);
+       if ((jobflags&(PSIGNALED|PSTOPPED|PTIME)) ||
+            !eq(dcwd->di_name, fp->p_cwd->di_name)) {
+               if (jobflags&PSTOPPED)
+                       printf("\n");
+               (void) pprint(pp, AREASON|SHELLDIR);
+       }
+       if ((jobflags&(PINTERRUPTED|PSTOPPED)) && setintr &&
            (!gointr || !eq(gointr, "-"))) {
            (!gointr || !eq(gointr, "-"))) {
-               pflush(pp);
-               pintr();
+               if ((jobflags & PSTOPPED) == 0)
+                       pflush(pp);
+               pintr1(0);
                /*NOTREACHED*/
        }
        reason = 0;
                /*NOTREACHED*/
        }
        reason = 0;
@@ -253,19 +245,18 @@ pjwait(pp)
 dowait()
 {
        register struct process *pp;
 dowait()
 {
        register struct process *pp;
+       int omask;
 
        pjobs++;
 
        pjobs++;
-       if (setintr)
-               sigrelse(SIGINT);
+       omask = sigblock(sigmask(SIGCHLD));
 loop:
 loop:
-       sighold(SIGCHLD);
        for (pp = proclist.p_next; pp; pp = pp->p_next)
        for (pp = proclist.p_next; pp; pp = pp->p_next)
-               if (pp->p_pid && pp->p_pid == pp->p_jobid &&
+               if (pp->p_pid && /* pp->p_pid == pp->p_jobid && */
                    pp->p_flags&PRUNNING) {
                    pp->p_flags&PRUNNING) {
-                       sigpause(SIGCHLD);
+                       sigpause(0);
                        goto loop;
                }
                        goto loop;
                }
-       sigrelse(SIGCHLD);
+       (void) sigsetmask(omask);
        pjobs = 0;
 }
 
        pjobs = 0;
 }
 
@@ -404,7 +395,7 @@ palloc(pid, t)
        }
        pp->p_next = proclist.p_next;
        proclist.p_next = pp;
        }
        pp->p_next = proclist.p_next;
        proclist.p_next = pp;
-       time(&pp->p_btime);
+       (void) gettimeofday(&pp->p_btime, (struct timezone *)0);
 }
 
 padd(t)
 }
 
 padd(t)
@@ -430,15 +421,25 @@ padd(t)
                }
                break;
 
                }
                break;
 
+       case TOR:
+       case TAND:
        case TFIL:
        case TFIL:
-               padd(t->t_dcar);
-               pads(" | ");
-               padd(t->t_dcdr);
-               return;
-
        case TLST:
                padd(t->t_dcar);
        case TLST:
                padd(t->t_dcar);
-               pads("; ");
+               switch (t->t_dtyp) {
+               case TOR:
+                       pads(" || ");
+                       break;
+               case TAND:
+                       pads(" && ");
+                       break;
+               case TFIL:
+                       pads(" | ");
+                       break;
+               case TLST:
+                       pads("; ");
+                       break;
+               }
                padd(t->t_dcdr);
                return;
        }
                padd(t->t_dcdr);
                return;
        }
@@ -463,12 +464,12 @@ pads(cp)
        if (cmdlen >= PMAXLEN)
                return;
        if (cmdlen + i >= PMAXLEN) {
        if (cmdlen >= PMAXLEN)
                return;
        if (cmdlen + i >= PMAXLEN) {
-               strcpy(cmdp, " ...");
+               (void) strcpy(cmdp, " ...");
                cmdlen = PMAXLEN;
                cmdp += 4;
                return;
        }
                cmdlen = PMAXLEN;
                cmdp += 4;
                return;
        }
-       strcpy(cmdp, cp);
+       (void) strcpy(cmdp, cp);
        cmdp += i;
        cmdlen += i;
 }
        cmdp += i;
        cmdlen += i;
 }
@@ -584,8 +585,9 @@ pprint(pp, flag)
                                case PINTERRUPTED:
                                case PSTOPPED:
                                case PSIGNALED:
                                case PINTERRUPTED:
                                case PSTOPPED:
                                case PSIGNALED:
-                                       if (flag&REASON || reason != SIGINT ||
-                                           reason != SIGPIPE)
+                                       if ((flag&(REASON|AREASON))
+                                           && reason != SIGINT
+                                           && reason != SIGPIPE)
                                                printf(format, mesg[pp->p_reason].pname);
                                        break;
 
                                                printf(format, mesg[pp->p_reason].pname);
                                        break;
 
@@ -626,11 +628,10 @@ prcomd:
                if (pp->p_flags&PPTIME && !(status&(PSTOPPED|PRUNNING))) {
                        if (linp != linbuf)
                                printf("\n\t");
                if (pp->p_flags&PPTIME && !(status&(PSTOPPED|PRUNNING))) {
                        if (linp != linbuf)
                                printf("\n\t");
-#ifndef VMUNIX
-                       ptimes(pp->p_utime, pp->p_stime, pp->p_etime-pp->p_btime);
-#else
-                       pvtimes(&zvms, &pp->p_vtimes, pp->p_etime - pp->p_btime);
-#endif
+                       { static struct rusage zru;
+                         prusage(&zru, &pp->p_rusage, &pp->p_etime,
+                           &pp->p_btime);
+                       }
                }
                if (tp == pp->p_friends) {
                        if (linp != linbuf)
                }
                if (tp == pp->p_friends) {
                        if (linp != linbuf)
@@ -653,30 +654,21 @@ prcomd:
 ptprint(tp)
        register struct process *tp;
 {
 ptprint(tp)
        register struct process *tp;
 {
-       time_t tetime = 0;
-#ifdef VMUNIX
-       struct vtimes vmt;
-#else
-       time_t tutime = 0, tstime = 0;
-#endif
+       struct timeval tetime, diff;
+       static struct timeval ztime;
+       struct rusage ru;
+       static struct rusage zru;
        register struct process *pp = tp;
 
        register struct process *pp = tp;
 
-       vmt = zvms;
+       ru = zru;
+       tetime = ztime;
        do {
        do {
-#ifdef VMUNIX
-               vmsadd(&vmt, &pp->p_vtimes);
-#else
-               tutime += pp->p_utime;
-               tstime += pp->p_stime;
-#endif
-               if (pp->p_etime - pp->p_btime > tetime)
-                       tetime = pp->p_etime - pp->p_btime;
+               ruadd(&ru, &pp->p_rusage);
+               tvsub(&diff, &pp->p_etime, &pp->p_btime);
+               if (timercmp(&diff, &tetime, >))
+                       tetime = diff;
        } while ((pp = pp->p_friends) != tp);
        } while ((pp = pp->p_friends) != tp);
-#ifdef VMUNIX
-       pvtimes(&zvms, &vmt, tetime);
-#else
-       ptimes(tutime, tstime, tetime);
-#endif
+       prusage(&zru, &ru, &tetime, &ztime);
 }
 
 /*
 }
 
 /*
@@ -719,8 +711,6 @@ dofg(v)
        do {
                pp = pfind(*v);
                pstart(pp, 1);
        do {
                pp = pfind(*v);
                pstart(pp, 1);
-               if (setintr)
-                       sigignore(SIGINT);
                pjwait(pp);
        } while (*v && *++v);
 }
                pjwait(pp);
        } while (*v && *++v);
 }
@@ -736,8 +726,6 @@ dofg1(v)
        okpcntl();
        pp = pfind(v[0]);
        pstart(pp, 1);
        okpcntl();
        pp = pfind(v[0]);
        pstart(pp, 1);
-       if (setintr)
-               sigignore(SIGINT);
        pjwait(pp);
 }
 
        pjwait(pp);
 }
 
@@ -795,14 +783,14 @@ dokill(v)
                                if (name = mesg[signum].iname)
                                        printf("%s ", name);
                                if (signum == 16)
                                if (name = mesg[signum].iname)
                                        printf("%s ", name);
                                if (signum == 16)
-                                       printf("\n");
+                                       putchar('\n');
                        }
                        }
-                       printf("\n");
+                       putchar('\n');
                        return;
                }
                if (digit(v[0][1])) {
                        signum = atoi(v[0]+1);
                        return;
                }
                if (digit(v[0][1])) {
                        signum = atoi(v[0]+1);
-                       if (signum < 1 || signum > NSIG)
+                       if (signum < 0 || signum > NSIG)
                                bferr("Bad signal number");
                } else {
                        name = &v[0][1];
                                bferr("Bad signal number");
                } else {
                        name = &v[0][1];
@@ -826,16 +814,18 @@ pkill(v, signum)
 {
        register struct process *pp, *np;
        register int jobflags = 0;
 {
        register struct process *pp, *np;
        register int jobflags = 0;
-       int pid;
+       int omask, pid, err = 0;
+       char *cp;
        extern char *sys_errlist[];
        extern char *sys_errlist[];
-       int err = 0;
 
 
+       omask = sigmask(SIGCHLD);
        if (setintr)
        if (setintr)
-               sighold(SIGINT);
-       sighold(SIGCHLD);
+               omask |= sigmask(SIGINT);
+       omask = sigblock(omask) & ~omask;
        while (*v) {
        while (*v) {
-               if (**v == '%') {
-                       np = pp = pfind(*v);
+               cp = globone(*v);
+               if (*cp == '%') {
+                       np = pp = pfind(cp);
                        do
                                jobflags |= np->p_flags;
                        while ((np = np->p_friends) != pp);
                        do
                                jobflags |= np->p_flags;
                        while ((np = np->p_friends) != pp);
@@ -846,18 +836,22 @@ pkill(v, signum)
                        case SIGTTIN:
                        case SIGTTOU:
                                if ((jobflags & PRUNNING) == 0) {
                        case SIGTTIN:
                        case SIGTTOU:
                                if ((jobflags & PRUNNING) == 0) {
-                                       printf("%s: Already stopped\n", *v);
+                                       printf("%s: Already stopped\n", cp);
                                        err++;
                                        goto cont;
                                }
                        }
                                        err++;
                                        goto cont;
                                }
                        }
-                       killpg(pp->p_jobid, signum);
+                       if (killpg(pp->p_jobid, signum) < 0) {
+                               printf("%s: ", cp);
+                               printf("%s\n", sys_errlist[errno]);
+                               err++;
+                       }
                        if (signum == SIGTERM || signum == SIGHUP)
                        if (signum == SIGTERM || signum == SIGHUP)
-                               killpg(pp->p_jobid, SIGCONT);
-               } else if (!digit(**v))
+                               (void) killpg(pp->p_jobid, SIGCONT);
+               } else if (!(digit(*cp) || *cp == '-'))
                        bferr("Arguments should be jobs or process id's");
                else {
                        bferr("Arguments should be jobs or process id's");
                else {
-                       pid = atoi(*v);
+                       pid = atoi(cp);
                        if (kill(pid, signum) < 0) {
                                printf("%d: ", pid);
                                printf("%s\n", sys_errlist[errno]);
                        if (kill(pid, signum) < 0) {
                                printf("%d: ", pid);
                                printf("%s\n", sys_errlist[errno]);
@@ -865,14 +859,13 @@ pkill(v, signum)
                                goto cont;
                        }
                        if (signum == SIGTERM || signum == SIGHUP)
                                goto cont;
                        }
                        if (signum == SIGTERM || signum == SIGHUP)
-                               kill(pid, SIGCONT);
+                               (void) kill(pid, SIGCONT);
                }
 cont:
                }
 cont:
+               xfree(cp);
                v++;
        }
                v++;
        }
-       sigrelse(SIGCHLD);
-       if (setintr)
-               sigrelse(SIGINT);
+       (void) sigsetmask(omask);
        if (err)
                error(NOSTR);
 }
        if (err)
                error(NOSTR);
 }
@@ -885,9 +878,9 @@ pstart(pp, foregnd)
        int foregnd;
 {
        register struct process *np;
        int foregnd;
 {
        register struct process *np;
-       int jobflags = 0;
+       int omask, jobflags = 0;
 
 
-       sighold(SIGCHLD);
+       omask = sigblock(sigmask(SIGCHLD));
        np = pp;
        do {
                jobflags |= np->p_flags;
        np = pp;
        do {
                jobflags |= np->p_flags;
@@ -902,12 +895,12 @@ pstart(pp, foregnd)
        } while((np = np->p_friends) != pp);
        if (!foregnd)
                pclrcurr(pp);
        } while((np = np->p_friends) != pp);
        if (!foregnd)
                pclrcurr(pp);
-       pprint(pp, foregnd ? NAME|JOBDIR : NUMBER|NAME|AMPERSAND);
+       (void) pprint(pp, foregnd ? NAME|JOBDIR : NUMBER|NAME|AMPERSAND);
        if (foregnd)
        if (foregnd)
-               ioctl(FSHTTY, TIOCSPGRP, &pp->p_jobid);
+               (void) ioctl(FSHTTY, TIOCSPGRP, (char *)&pp->p_jobid);
        if (jobflags&PSTOPPED)
        if (jobflags&PSTOPPED)
-               killpg(pp->p_jobid, SIGCONT);
-       sigrelse(SIGCHLD);
+               (void) killpg(pp->p_jobid, SIGCONT);
+       (void) sigsetmask(omask);
 }
 
 panystop(neednl)
 }
 
 panystop(neednl)
@@ -967,6 +960,7 @@ match:
                bferr("No job matches pattern");
        else
                bferr("No such job");
                bferr("No job matches pattern");
        else
                bferr("No such job");
+       /*NOTREACHED*/
 }
 
 /*
 }
 
 /*
@@ -1019,7 +1013,7 @@ pfork(t, wanttty)
 {
        register int pid;
        bool ignint = 0;
 {
        register int pid;
        bool ignint = 0;
-       int pgrp;
+       int pgrp, omask;
 
        /*
         * A child will be uninterruptible only under very special
 
        /*
         * A child will be uninterruptible only under very special
@@ -1036,13 +1030,12 @@ 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.
         */
-       sighold(SIGCHLD);
+       omask = sigblock(sigmask(SIGCHLD));
        while ((pid = fork()) < 0)
                if (setintr == 0)
                        sleep(FORKSLEEP);
                else {
        while ((pid = fork()) < 0)
                if (setintr == 0)
                        sleep(FORKSLEEP);
                else {
-                       sigrelse(SIGINT);
-                       sigrelse(SIGCHLD);
+                       (void) sigsetmask(omask);
                        error("No more processes");
                }
        if (pid == 0) {
                        error("No more processes");
                }
        if (pid == 0) {
@@ -1050,32 +1043,30 @@ pfork(t, wanttty)
                pgrp = pcurrjob ? pcurrjob->p_jobid : getpid();
                pflushall();
                pcurrjob = PNULL;
                pgrp = pcurrjob ? pcurrjob->p_jobid : getpid();
                pflushall();
                pcurrjob = PNULL;
-               timesdone = 0;
                child++;
                if (setintr) {
                        setintr = 0;            /* until I think otherwise */
                child++;
                if (setintr) {
                        setintr = 0;            /* until I think otherwise */
-                       sigrelse(SIGCHLD);
                        /*
                         * Children just get blown away on SIGINT, SIGQUIT
                         * unless "onintr -" seen.
                         */
                        /*
                         * Children just get blown away on SIGINT, SIGQUIT
                         * unless "onintr -" seen.
                         */
-                       signal(SIGINT, ignint ? SIG_IGN : SIG_DFL);
-                       signal(SIGQUIT, ignint ? SIG_IGN : SIG_DFL);
+                       (void) signal(SIGINT, ignint ? SIG_IGN : SIG_DFL);
+                       (void) signal(SIGQUIT, ignint ? SIG_IGN : SIG_DFL);
                        if (wanttty >= 0) {
                                /* make stoppable */
                        if (wanttty >= 0) {
                                /* make stoppable */
-                               signal(SIGTSTP, SIG_DFL);
-                               signal(SIGTTIN, SIG_DFL);
-                               signal(SIGTTOU, SIG_DFL);
+                               (void) signal(SIGTSTP, SIG_DFL);
+                               (void) signal(SIGTTIN, SIG_DFL);
+                               (void) signal(SIGTTOU, SIG_DFL);
                        }
                        }
-                       signal(SIGTERM, parterm);
+                       (void) signal(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);
+                       (void) signal(SIGINT, SIG_IGN);
+                       (void) signal(SIGQUIT, SIG_IGN);
                }
                if (wanttty > 0)
                }
                if (wanttty > 0)
-                       ioctl(FSHTTY, TIOCSPGRP, &pgrp);
+                       (void) ioctl(FSHTTY, TIOCSPGRP, (char *)&pgrp);
                if (wanttty >= 0 && tpgrp >= 0)
                if (wanttty >= 0 && tpgrp >= 0)
-                       setpgrp(0, pgrp);
+                       (void) setpgrp(0, pgrp);
                if (tpgrp > 0)
                        tpgrp = 0;              /* gave tty away */
                /*
                if (tpgrp > 0)
                        tpgrp = 0;              /* gave tty away */
                /*
@@ -1084,18 +1075,12 @@ pfork(t, wanttty)
                 * Then the parser would have to know about nice/nohup/time
                 */
                if (t->t_dflg & FNOHUP)
                 * Then the parser would have to know about nice/nohup/time
                 */
                if (t->t_dflg & FNOHUP)
-                       signal(SIGHUP, SIG_IGN);
-               if (t->t_dflg & FNICE) {
-/* sigh...
-                       nice(20);
-                       nice(-10);
-*/
-                       nice(t->t_nice);
-               }
-
+                       (void) signal(SIGHUP, SIG_IGN);
+               if (t->t_dflg & FNICE)
+                       (void) setpriority(PRIO_PROCESS, 0, t->t_nice);
        } else {
                palloc(pid, t);
        } else {
                palloc(pid, t);
-               sigrelse(SIGCHLD);
+               (void) sigsetmask(omask);
        }
 
        return (pid);
        }
 
        return (pid);