Jump to content

Sigaction: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
No edit summary
Line 2: Line 2:


Signal handlers installed by the <code>signal()</code> interface will be uninstalled immediately prior to execution of the handler. Permenant handlers must therefore be reinstalled by a call to <code>signal()</code> during the handler's execution, causing unreliability in the event a signal of the same type is recieved during the handler's execution but before the reinstall. Handlers installed by the <code>sigaction()</code> interface can be installed permanently and a custom set of signals can be blocked during the execution of the handler. These signals will be unblocked immediately following the normal termination of the handler (but not in the event of an abnormal termination such as a C++ exception throw.)
Signal handlers installed by the <code>signal()</code> interface will be uninstalled immediately prior to execution of the handler. Permenant handlers must therefore be reinstalled by a call to <code>signal()</code> during the handler's execution, causing unreliability in the event a signal of the same type is recieved during the handler's execution but before the reinstall. Handlers installed by the <code>sigaction()</code> interface can be installed permanently and a custom set of signals can be blocked during the execution of the handler. These signals will be unblocked immediately following the normal termination of the handler (but not in the event of an abnormal termination such as a C++ exception throw.)

To <code>catch(...)</code> signals translated into C++ exceptions, special compiler switches may be necessary on some platforms such as [[-fnon-call-exceptions]] for the gcc compiler.

Revision as of 20:04, 26 May 2005

The int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) function defined in #include <signal.h> specifies the action which should be taken when a signal is received. The sigaction() function provides an interface for reliable signals in replacement of the unreliable and deprecated signal() function.

Signal handlers installed by the signal() interface will be uninstalled immediately prior to execution of the handler. Permenant handlers must therefore be reinstalled by a call to signal() during the handler's execution, causing unreliability in the event a signal of the same type is recieved during the handler's execution but before the reinstall. Handlers installed by the sigaction() interface can be installed permanently and a custom set of signals can be blocked during the execution of the handler. These signals will be unblocked immediately following the normal termination of the handler (but not in the event of an abnormal termination such as a C++ exception throw.)

To catch(...) signals translated into C++ exceptions, special compiler switches may be necessary on some platforms such as -fnon-call-exceptions for the gcc compiler.