System Calls Related to Signal Handling
As stated in the introduction of this chapter, programs
running in User Mode are allowed to send and receive signals. This means
that a set of system calls must be defined to allow these kinds of
operations. Unfortunately, for historical reasons, several system calls
exist that serve essentially the same purpose. As a result, some of
these system calls are never invoked. For instance, sys_sigaction( ) and sys_rt_sigaction( ) are almost identical, so
the sigaction( ) wrapper function included in the C library ends up
invoking sys_rt_sigaction( ) instead
of sys_sigaction( ). We will describe
some of the most significant system calls in the following
sections.
The kill( ) System Call
The kill(pid,sig)
system call is commonly used to send signals to conventional processes
or multithreaded applications; its corresponding service routine is
the sys_kill( ) function. The
integer pid parameter has several
meanings, depending on its numerical value:
- pid > 0
The
sigsignal is sent to the thread group of the process whose PID is equal topid.- pid = 0
The
sigsignal is sent to all thread groups of the processes in the same process group as the calling process.- pid = -1
The signal is sent to all processes, except swapper (PID 0), init (PID 1), and
current.- pid < -1
The signal is sent to all thread groups of the processes in the process group -pid.
The sys_kill( ) function sets
up a minimal siginfo_t table for
the signal, and then invokes kill_something_info( ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access