- Sigaction
In computing,
sigaction
is a function API defined byPOSIX to give the programmer access to what should be a program's behavior when receiving specific OS signals.General
In
Unix-like operating systems, one means ofinter-process communication is through signals. When an executing unit (process or thread) receives a signal from the OS, it should react in some way defined by the datasheet and the conventional meaning of this signal (ie. by dumping its data, stopping execution, synchronizing something...).The
sigaction()
system call is used to declare the behavior of the program should it receive one particular non-system-reserved signal. This is done by giving along with the system call a structure containing, among others, a function pointer to the signal handling routine. Some predefined signals (such asSIGKILL
) have locked behavior that is handled by the system and cannot be overridden by such system calls.Replacement of deprecated
signal()
The
sigaction()
function provides an interface for reliable signals in replacement of the unreliable and deprecatedsignal()
function. Signal handlers installed by thesignal()
interface will be uninstalled immediately prior to execution of the handler. Permanent handlers must therefore be reinstalled by a call tosignal()
during the handler's execution, causing unreliability in the event a signal of the same type is received during the handler's execution but before the reinstall. Handlers installed by thesigaction()
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.)Use in C++
In C++, the
try {/* ... */} catch {/* ... */}
programming structure may be (depending on host platforms) based on signalling. Tocatch
signals translated into C++ exceptions, special compiler switches may be necessary on some platforms such as-fnon-call-exceptions
for GCC.Fact|date=August 2008References
*
Wikimedia Foundation. 2010.