Signal Handling in System V
katz / kowalski
ec at ttidca.TTI.COM
Sat Feb 11 11:29:54 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?
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 doesn't want */
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.
More information about the Comp.unix.wizards
mailing list