signal(2) SDK R4.11 signal(2)
NAME
signal - specify what to do upon presentation of a signal
SYNOPSIS
#include <signal.h>
void (* signal (signalnumber, action))()
int signalnumber;
void (*action)();
where:
signalnumber Any of the valid signals except SIGKILL (see
<sys/signal.h>, which is included into <signal.h>, for
a complete list)
action Handler for the signal: SIG_DFL, SIG_IGN, or a
function address
DESCRIPTION
This manual page describes the default signal behavior. If you
define the _BSD_SIGNAL_FLAVOR macro or if you define only the
_BSD_SOURCE macro when you compile your C application, however, you
will get the behavior described in berksignal(3C) (also found as
signal(3C)). For more information about the _BSD_SIGNAL_FLAVOR and
_BSD_SOURCE macros and the capabilities they provide, see Porting
Applications to the DG/UX (Trademark) System.
Signal allows the calling process to choose one of three ways to
handle the presentation of a specific signal. Signalnumber
specifies the signal, and action specifies the choice. The actions
prescribed by action are as follows.
SIG_DFL Terminate the process.
The process's signal action vector entry for signalnumber is
set to `default'. If the signal signalnumber was pended and
signalnumber is not SIGKILL, the pended signal is lost. The
set of blocked signals remains unchanged.
When the signal signalnumber is presented to the process, it
will cause the process either to terminate, stop, ignore the
signal, or terminate with a core dump depending on the
signal's type (see <sys/signal.h>).
If a core dump is indicated, the receiving process must have
adequate permission to do so.
SIG_IGN Ignore signal.
The process's signal action vector entry for signalnumber is
set to `ignore'. The set of blocked signals remains
unchanged.
When the signal signalnumber is presented to the process, it
will be discarded.
SIGKILL cannot be ignored.
address Catch signal.
The process's signal action vector entry for signalnumber is
set to `catch'. If the signal signalnumber was pended and
signalnumber is not SIGKILL, the pended signal is lost. The
set of blocked signals remains unchanged.
When the signal signalnumber is sent to the process, it will
cause the signal handler specified by action to be invoked.
Upon invocation of the signal handler the first argument to
the handler function will always be the number of the caught
signal. Other signal state information may be passed to the
handler via arguments depending upon the current software
development environment. See siginfo(5) and sde-target(1)
for details.
The following attributes are set for the signal action vector
entry for signalnumber:
· The signal mask addend is cleared. Thus, no
additional signals will be blocked when the signal
handler is invoked.
· The signal stack choice specifies the current
execution stack. Thus, no stack change is made.
· If signalnumber is not SIGILL, SIGTRAP, or SIGPWR,
the system first sets the signal action to SIGDFL
before executing the signal handler. For signals
whose new signal action is set to SIGDFL, the
occurrence of multiple signals may cause some signals
to be lost or may cause the process to terminate.
· System calls interrupted by signal signalnumber will
not be restarted.
The value of the signal action is not verified or
access checked at the time of the call. If it is
invalid, results are undefined when the signal is
caught.
SIGKILL cannot be caught.
After a fork, the child process inherits all software signal
structures, except that the pending signal vector is cleared.
Exec modifies the software signal structures in the following manner:
1) The signal action for signals set to `catch' is changed to
`default'.
2) The signal stack context is discarded.
3) All other software signal structures are unchanged.
Setting the signal SIGCLD to SIG_IGN affects exit and wait in the
following manner:
1) The calling process's child processes will be cleaned up by the
parent when the parent issues its next system call (checks signals).
2) If the calling process later performs a wait operation, wait will
suspend the calling process until all child processes have terminated
and will return with the error condition ECHILD.
Signal will fail, and the signal handler will be unchanged if an
error occurs.
ACCESS CONTROL
No access is required to install a signal handler.
The receiving process is granted permission to produce a core dump
file provided:
· the effective-user-id and the real-user-id of the receiving
process are equal, and
· the receiving process has adequate file system permission to
create or rewrite the core dump file.
RETURN VALUE
oldaction Completed successfully. The previous signal handler for
signalnumber is returned.
-1 An error occurred. errno is set to indicate the error.
DIAGNOSTICS
Errno may be set to the following error code:
EINVAL Signalnumber is an illegal signal number, including
SIGKILL.
SEE ALSO
kill(2), pause(2), ptrace(2), wait(2), berksignal(3C), sde-
target(1).
STANDARDS
When using m88kbcs as the Software Development Environment target,
the signal function will be emulated using BCS system calls. Since
this is an emulation requiring several BCS system calls, a slight
performance degradation may be noticed in comparison to using signal
in /lib/libc.a.
Licensed material--property of copyright holder(s)