/bin/sh loops if SIGSEGV ignored

Mark Bartelt mark at sickkids.UUCP
Wed Jul 26 23:38:59 AEST 1989


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 at sickkids.utoronto
416/598-6442                          INTERNET: mark at sickkids.toronto.edu



More information about the Comp.bugs.4bsd.ucb-fixes mailing list