Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 5: Locking and Interprocess Communication


Table 5-2 shows which signals are assigned to which default handler. The corresponding infor-
mation can be obtained from the macrosSIG_KERNEL_ONLY_MASK,SIG_KERNELCOREDUMP
MASK,SIG_KERNEL_IGNORE_MASK,andSIG_KERNEL_STOP_MASKin<signal.h>.


Table 5-2: Default Actions for Standard Signals


Action Signals

Ignore SIGCONT,SIGCHLD,SIGWINCH,SIGURG

Terminate SIGHUP,SIGINT,SIGKILL,SIGUSR1,SIGUSR2,SIGALRM,SIGTERM,SIGVTALRM,
SIGPROF,SIGPOLL,SIGIO,SIGPWRand all real-time signals.

Stop SIGSTOP,SIGTSTP,SIGTTIN,SIGTTOU

Core dump SIGQUIT,SIGILL,SIGTRAP,SIGABRT,SIGBUS,SIGFPE,SIGSEGV,SIGXCPU,SIGXFSZ,
SIGSYS,SIGXCPU,SIGEMT

All blocked signals are defined by theblockedelement of the task structure. Thesigset_tdata type
used is a bitmask that must contain (at least) as many positions as the number of signals supported. For
this purpose, the kernel uses an array ofunsigned longswhose size is calculated on the basis of_NSIG
and_NSIG_BPW(bits per word).


<asm-arch/signal.h>
#define _NSIG 64
#define _NSIG_BPW 32
#define _NSIG_WORDS (_NSIG / _NSIG_BPW)

typedef struct {
unsigned long sig[_NSIG_WORDS];
} sigset_t;

pendingis the final task structure element of relevance for signal handling. It creates a linked list of all
signals raised and still to be handled by the kernel. The following data structure is used:


<signal.h>
struct sigpending {
struct list_head list;
sigset_t signal;
};

listmanages all pending signals in a doubly linked list, whilesignal, with the bitmask described above,
specifies the numbers of all signals still to be handled. The list elements are instances of typesigqueue,
which is essentially defined as follows:


<signal.h>
struct sigqueue {
struct list_head list;
siginfo_t info;
};

The individual entries are linked by means oflist.Thesiginfo_tdata structure contains more detailed
information on the pending signals.

Free download pdf