Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ signal(2) — 4D1 2.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

intro(2)

kill(2)

pause(2)

ptrace(2)

wait(2)

setjmp(3C)

sigset(2)

kill(1)



     SIGNAL(2)                                               SIGNAL(2)



     NAME
          signal - specify what to do upon receipt of a signal

     SYNOPSIS
          #include <signal.h>

          void (*signal (sig, func))()
          int sig;
          void (*func)();

     DESCRIPTION
          signal allows the calling process to choose one of three
          ways in which it is possible to handle the receipt of a
          specific signal.  Sig specifies the signal and func
          specifies the choice.

          Sig can be assigned any one of the following except SIGKILL:

         SIGHUP     01      hangup
         SIGINT     02      interrupt
[1] quit
SIGQUIT 03[1] illegal instruction (not reset when caught)
SIGILL 04[1] trace trap (not reset when caught)
SIGTRAP 05[1] IOT instruction
SIGIOT 06[1] EMT instruction
SIGEMT 07[1] floating point exception
SIGFPE 08
SIGKILL 09 kill (cannot be caught or ignored)
[1] bus error
SIGBUS 10[1] segmentation violation
SIGSEGV 11[1] bad argument to system call
SIGSYS 12
SIGPIPE 13 write on a pipe with no one to read it
SIGALRM 14 alarm clock
SIGTERM 15 software termination signal
SIGUSR1 16 user-defined signal 1
SIGUSR2 17 user-defined signal 2
[2] death of a child
SIGCLD 18[2] power fail
SIGPWR 19[3] selectable event pending
SIGPOLL 22
SIGIO 23 input/output possible
SIGURG 24 urgent condition on IO channel
[2] window size changes
SIGWINCH 25
Func is assigned one of three values: SIGDFL, SIGIGN, or
a function address. SIGDFL, and SIGIGN, are defined in
the include file signal.h. Each is a macro that expands to
a constant expression of type pointer to function returning
void, and has a unique value that matches no declarable
function.
The actions prescribed by the values of func are as follows:
SIGDFL - terminate process upon receipt of a signal
Page 1 (last mod. 8/20/87)
SIGNAL(2) SIGNAL(2)
Upon receipt of the signal sig, the receiving
process is to be terminated with all of the
consequences outlined in exit(2). See NOTE [1]
below.
SIGIGN - ignore signal
The signal sig is to be ignored.
Note: the signal SIGKILL cannot be ignored.
function address - catch signal
Upon receipt of the signal sig, the receiving
process is to execute the signal-catching function
pointed to by func. The signal number sig will be
passed as the only argument to the signal-catching
function. Additional arguments are passed to the
signal-catching function for hardware-generated
signals. Before entering the signal-catching
function, the value of func for the caught signal
will be set to SIGDFL unless the signal is
SIGILL, SIGTRAP, or SIGPWR.
Upon return from the signal-catching function, the
receiving process will resume execution at the
point it was interrupted. See WARNINGS.
When a signal that is to be caught occurs during a
read(2), a write(2), an open(2), or an ioctl(2)
system call on a slow device (like a terminal; but
not a file), during a pause(2) system call, or
during a wait(2) system call that does not return
immediately due to the existence of a previously
stopped or zombie process, the signal catching
function will be executed and then the interrupted
system call may return a -1 to the calling process
with errno set to EINTR.
signal will not catch an invalid function
argument, func, and results are undefined when an
attempt is made to execute the function at the bad
address.
Note: The signal SIGKILL cannot be caught.
A call to signal cancels a pending signal sig except for a
pending SIGKILL signal.
signal will fail if sig is an illegal signal number,
including SIGKILL. [EINVAL]
NOTES
[1] If SIGDFL is assigned for these signals, in addition to
Page 2 (last mod. 8/20/87)
SIGNAL(2) SIGNAL(2)
the process being terminated, a ``core image'' will be
constructed in the current working directory of the
process, if the following conditions are met:
The effective user ID and the real user ID of
the receiving process are equal.
An ordinary file named core exists and is
writable or can be created. If the file must be
created, it will have the following properties:
a mode of 0666 modified by the file
creation mask [see umask(2)]
a file owner ID that is the same as the
effective user ID of the receiving
process.
a file group ID that is the same as the
effective group ID of the receiving
process
NOTE: The core file may be truncated to exclude data and/or
stack information if the file size is larger than ulimit.
(See ulimit(2).)
[2] For the signals SIGCLD , SIGWINCH , and SIGPWR, func is
assigned one of three values: SIGDFL, SIGIGN, or a
function address. The actions prescribed by these
values are:
SIGDFL - ignore signal
The signal is to be ignored.
SIGIGN - ignore signal
The signal is to be ignored. Also, if sig is
SIGCLD, the calling process's child processes
will not create zombie processes when they
terminate [see exit(2)].
function address - catch signal
If the signal is SIGPWR or SIGWINCH , the
action to be taken is the same as that
described above for func equal to function
address. The same is true if the signal is
SIGCLD with one exception: while the process
is executing the signal-catching function, any
terminating child process will be queued. The
wait system call removes the first entry of
the queue. If the signal system call is used
with SIGCLD the signal handler is re-attached,
and, if the queue is not empty, SIGCLD is re-
Page 3 (last mod. 8/20/87)
SIGNAL(2) SIGNAL(2)
raised before signal returns.
In addition, SIGCLD affects the wait, and exit system
calls as follows:
wait If the func value of SIGCLD is set to SIGIGN
and a wait is executed, the wait will block
until all of the calling process's child
processes terminate; it will then return a
value of -1 with errno set to ECHILD.
exit If in the exiting process's parent process the
func value of SIGCLD is set to SIGIGN, the
exiting process will not create a zombie
process.
When processing a pipeline, the shell makes the last
process in the pipeline the parent of the proceeding
processes. A process that may be piped into in this
manner (and thus become the parent of other processes)
should take care not to set SIGCLD to be caught.
[3] SIGPOLL is issued when a file descriptor corresponding
to a STREAMS [see intro(2)] file has a "selectable"
event pending. A process must specifically request that
this signal be sent using the I_SETSIG ioctl call.
Otherwise, the process will never receive SIGPOLL.
WARNINGS
Signals raised by the instruction stream, SIGILL, SIGEMT,
SIGBUS, SIGSEGV will cause infinite loops if their handler
returns, or the action is set to SIGIGN.
SEE ALSO
intro(2), kill(2), pause(2), ptrace(2), wait(2), setjmp(3C),
sigset(2).
kill(1) in the User's Reference Manual.
DIAGNOSTICS
Upon successful completion, signal returns the previous
value of func for the specified signal sig. Otherwise, a
value of SIG_ERR is returned and errno is set to indicate
the error. SIG_ERR is defined in the include file signal.h.
ORIGIN
AT&T V.3
Page 4 (last mod. 8/20/87)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026