Sigaction

Sigaction

In computing, sigaction is a function API defined by POSIX 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 of inter-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 as SIGKILL) 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 deprecated signal() function. Signal handlers installed by the signal() interface will be uninstalled immediately prior to execution of the handler. Permanent 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 received 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.)

Use in C++

In C++, the try {/* ... */} catch {/* ... */} programming structure may be (depending on host platforms) based on signalling. To catch signals translated into C++ exceptions, special compiler switches may be necessary on some platforms such as -fnon-call-exceptions for GCC.Fact|date=August 2008

References

*


Wikimedia Foundation. 2010.

Игры ⚽ Поможем решить контрольную работу

Look at other dictionaries:

  • Сигналы (UNIX) — У этого термина существуют и другие значения, см. Сигнал (значения). Сигналы в UNIX, Unix подобных и других POSIX совместимых операционных системах являются одним из способов взаимодействия между процессами (англ. IPC, inter process… …   Википедия

  • Gets — gets  функция, входящая в Стандартную библиотеку языка Си, объявляемая в заголовочном файле stdio.h, которая считывает строку стандартного ввода и помещает ее в буфер, созданный вызывающей функцией. Содержание 1 Реализация 2 Альтернативы …   Википедия

  • gets — gets  функция, входящая в Стандартную библиотеку языка Си, объявляемая в заголовочном файле stdio.h, которая считывает строку стандартного ввода и помещает ее в буфер, созданный вызывающей функцией. Содержание 1 Реализация 2 Альтернативы …   Википедия

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”