POSIX signal 小整理

What is signals?

Signals are a limited form of inter-process communication (IPC). A signal is an asynchronous notification sent to a process or to a specific thread within the same process in order to notify it of an event that occurred.

Why signals?

Embedded programs may find signals useful for interprocess communications, as the computational and memory footprint for signals is small.

How signals works?

When a signal is sent, the operating system interrupts the target process’ normal flow of executionto deliver the signal. Execution can be interrupted during any non-atomic instruction.

If the process has previously registered a signal handler, that routine is executed. Otherwise, the default signal handler is executed.

Sending signals

Typing certain key combinations at the controlling terminal of a running process causes the system to send it certain signals:

  • Ctrl-C (in older Unixes, DEL) sends an INT signal (“interrupt”, SIGINT); by default, this causes the process to terminate.
  • Ctrl-Z sends a TSTP signal (“terminal stop”, SIGTSTP); by default, this causes the process to suspend execution.
  • Ctrl-\ sends a QUIT signal (SIGQUIT); by default, this causes the process to terminate and dump core.

POSIX signals


The SIGINT signal is sent to a process by its controlling terminal when a user wishes to interruptthe process. This is typically initiated by pressing Ctrl+C, but on some systems, the “delete” character or “break” key can be used.


The SIGQUIT signal is sent to a process by its controlling terminal when the user requests that the process quit and perform a core dump.


The SIGTERM signal is sent to a process to request its termination. Unlike the SIGKILL signal, it can be caught and interpreted or ignored by the process. This allows the process to perform nice termination releasing resources and saving state if appropriate. SIGINT is nearly identical to SIGTERM.


The SIGKILL signal is sent to a process to cause it to terminate immediately (kill). In contrast to SIGTERM and SIGINT, this signal cannot be caught or ignored, and the receiving process cannot perform any clean-up upon receiving this signal.

The command killall -9 has a similar, while dangerous effect, when executed e.g. in Linux; it doesn’t let programs save unsaved data. It has other options, and with none, uses the safer SIGTERM signal.

Leave a Reply

Close Menu