Question: SYS V Signal Handling

katz / kowalski ec at ttidca.TTI.COM
Fri Feb 17 03:55:43 AEST 1989


I have some questions about certain aspects of signal handling
in System V (which may be applicable to other versions).

  1).  Apparently if a process has a pending signal at the time
       it does a fork, the forked process also ends up with the
       same pending signal.  Is this result intentional and if
       so, why would anyone want signals to work this way, i.e.,
       how is this useful?  Note that BSD4.3 does NOT work this
       way.

   2). What is the safest way to ensure that a child process
       starts out "fresh" relative to signals (assuming sigset
       is used)?  One sequence which I believe should work is:

       (in parent)

	 sighold(sig);    /* to prevent the forked process from
                             receiving a signal it is not
			     prepared to cope with */
	 fork();
	 sigrelse(sig);

       (in forked process - prior to exec)

         signal(sig, SIG_DFL); /* to clear any pending signal
                                  and reset the signal action
                                  routine. note: sigset does not
                                  remove a pending signal */

	 sigrelse(sig);        /* to release any signal hold.
				  note: signal does not remove a
				  signal hold */
	 exec(..);

       Is the preceding necessary and sufficient?

Thanks for any response.
-- 
Bruce Katz
Citicorp TTI
3100 Ocean Park Blvd.   (213) 452-9111, x2942
Santa Monica, CA  90405 {csun|philabs|psivax}!ttidca!ec



More information about the Comp.unix.wizards mailing list