Process Handling in Linux
POS 420
October 11, 2005
In Linux processes communicate with each other and with the kernel to coordinate their
activities. Linux supports a number of Inter-Process Communication (IPC) mechanisms.
Signals and pipes are two of them but Linux also supports the System V IPC mechanisms
named after the Unix TM release in which they first appeared. Signals are one of the oldest
inter-process communication methods used by Unix TM systems. The common Linux
shells all allow redirection. For example $ ls | pr | lpr pipes the output from the ls
command listing the directorys files into the standard input of the pr command which
paginates them. Finally the standard output from the pr command is piped into the standard
input of the lpr command which prints the results on the default printer.
(2005,www.tldp.org)
They are used to signal asynchronous events to one or more processes. A signal could be
generated by a keyboard interrupt or an error condition such as the process attempting to
access a non-existent location in its virtual memory. Signals are also used by the shells to
signal job control commands to their child processes. There are a set of defined signals that
the kernel can generate or that can be generated by other processes in the system, provided
that they have the correct privileges. Processes can choose to ignore most of the signals
that are generated, with two notable exceptions: neither the SIGSTOP signal which causes
a process to halt its execution nor the SIGKILL signal which causes a process to exit can
be ignored. Otherwise though, a process can choose just how it wants to handle the various
signals. Processes can block the signals and, if they do not block them, they can either
choose to handle them themselves or allow the kernel to handle them. If the kernel handles
the signals, it will do the default actions required for this signal. For example, the default
action when a process receives the SIGFPE (floating point exception) signal is to core
dump and then exit. Signals have no inherent relative priorities. If two signals are
generated for a process at the same time then they may be presented to the process or
handled in any order. Also there is no mechanism for handling multiple signals of the same
kind. There is no way that a process can tell if it received 1 or 42 SIGCONT signals.
(2005,www.tldp.org)
Linux implements signals using information stored in the task_struct for the process. The
number of supported signals is limited to the word size of the processor. Processes with a
word size of 32 bits can have 32 signals whereas 64 bit processors like the Alpha AXP may
have up to 64 signals. The currently pending signals are kept in the signal field with a
mask of blocked signals held in blocked. With the exception of SIGSTOP and SIGKILL,
all signals can be blocked. If a blocked signal is generated, it remains pending until it is
unblocked. Linux also holds information about how each process handles every possible