CS 3733 Operating Systems
Lecture 8 [9/22/97]: Signals
Reading: Sections 5.1-5.4 and 5.6 of Pup
Basic terminology
- Signal - software notification of an event.
- Lifetime of a signal - time between generation and delivery
- Delivery of a signal - takes place when process takes action on
signal.
- A pending signal has been generated but not yet delivered.
- Signal handler - function executed when is delivered.
- Signal mask - list of currently blocked signals for a process.
- A blocked signal - is a signal that
is prevented from being delivered to a process.
- Signal set - a list of signals used in various signal operations.
Sending a signal
- Signals are specified by integers.
symbol.h
contains
their symbolic names.
-
kill
sends specified signal to a process or a group of processes.
-
raise
sends specified signal to self.
- Certain keystrokes cause the keyboard device driver to generate
a signal which is sent to the foreground process group:
-
INTR
(ctrl-c) generates SIGINT
-
QUIT
(ctrl-|) generates SIGQUIT
-
SUSP
(ctrl-z) generates SIGSTOP
-
DSUSP
(ctrl-y) generates SIGCONT
-
alarm
sends a SIGALRM
to caller.
Signal masks and signal sets:
- Signal mask is associated with blocking of signals. These
signals are not lost---their delivery is just postponed.
- Signal set operations:
sigemptyset
, sigfillset
,
sigaddset
, sigdelset
, sigismember
- Signal mask operations are performed by calling
sigprocmask
with SIG_BLOCK
, SIG_UNBLOCK
and SIG_SETMASK
.
Catching signals
- In order to catch a signal, you must install a handler with
sigaction
-
SIG_DFL
is the default handler.
-
SIG_IGN
indicates the signal should be thrown away.
(You should understand why this is different than blocking a signal.)
-
pause
suspends a process until a signal is delivered.
-
sigsuspend
does an atomic unblock and suspend for
a set of signals.
System calls and signals
- What does it mean to be asynch-signal safe?
- Interruption of long calls.
Revision Date: 9/20/97