Signal Handling--ref
/ Establish the signal handler. / / Create the child process. / / Busy wait for the child to send a signal. / / Now continue execution. / return 0;
SIG_IGN. But it is useful to block signals briefly,to prevent them from interrupting sensitive operations. For instance:
sigprocmask function to block signals while you modify global variables that are also modified by the handlers for these signals.
sigprocmaskgives you a way to prevent interrupts during critical parts of your code. If signals arrive in that part of the program,they are delivered later,after you unblock them. sig_atomic_t(see section),then the signal handler could run when the rest of the program has only half finished reading or writing the data. This would lead to confusing consequences.
sig_atomic_t; you would like to test the flag and perform the action if the flag is not set. This is unreliable. Suppose the signal is delivered immediately after you test the flag,but before the consequent action: then the program will perform the action even though the signal has arrived.
`signal.h'.
|