[comp.bugs.4bsd] /bin/sh loops if SIGSEGV ignored

mark@sickkids.UUCP (Mark Bartelt) (07/26/89)

Problem:  A shell spawned as a subprocess of a process that ignores SIGSEGV
tends to get into a state in which it loops forever.  For example, running
the program ...

        /* x.c */
        #include <signal.h>
        main()
        {
                signal(SIGSEGV,SIG_IGN);
                system("date");
        }

... results in the following:

          PID TT STAT  TIME COMMAND
        26027 01 I     0:00 x
        26028 01 I     0:00 sh -c date
        26029 01 R     6:54 sh -c date

---------------

Fix:  In fault.c/getsig(), change

        IF trapflg[i=n]&SIGMOD ORF ignsig(i)==0
to
        IF trapflg[i=n]&SIGMOD ORF ignsig(i)==0 ORF i==MEMF

It would probably also be wise to make the shell disallow attempts to trap
SIGSEGV.  In xec.c/execute(), eight lines down from "case SYSTRAP:", change

        IF (i=stoi(*com))>=MAXTRAP ORF i<MINTRAP
to
        IF (i=stoi(*com))>=MAXTRAP ORF i<MINTRAP ORF i==MEMF

---------------

Mark Bartelt                          UUCP: {utzoo,decvax}!sickkids!mark
Hospital for Sick Children, Toronto   BITNET: mark@sickkids.utoronto
416/598-6442                          INTERNET: mark@sickkids.toronto.edu