Implementing Signal Handling

Table 5-3 shows an overview of the most important system calls used by the kernel to implement signal handling. In practice, there are a few more, some for historical reasons, some to ensure compatibility with various standards — above all, POSIX.

Although the signal mechanism appears to be very simple, its implementation is made more complicated by the many subtleties and details that must be taken into account. Because these reveal no significant information on the implementation structure, I will not discuss specific cases but restrict myself to a description of the key mechanisms.

Table 5-3: Some System Calls Relating to Signals

System call



Sends a signal to all processes of a process group.


Sends a signal to a single process.


Checks whether there are pending signals.


Manipulates a bitmask of blocked signals.


Sleeps until a specific signal is received.

Sending Signals

Despite their names, kill and tkill send any signal to a process group or to a single process, respectively. As both functions are basically identical,14 I discuss only sys_tkill, whose code flow diagram is shown in Figure 5-9.

Figure 5-9: Code flow diagram for sys_tkill.

14sys_kill sends the signal to several processes that are interpreted according to the form of the PID passed. G pid > 0 sends the signal to the process with the specified PID.

G pid = 0 sends the signal to all members of the process group of the task that sent the signal. G pid = —1 sends the signal to all processes with pid > 1.

G pid = —pgrp < —1 sends the signal to all members of the pgrp process group.

Once find_task_by_vpid has found the task structure of the target process, the kernel delegates the job of checking whether the process has the permissions needed to send the signal to check_kill_permission, which uses the following query:

Continue reading here: Kernelsignalc

Was this article helpful?

0 0