berk_signal(3C) SDK R4.11 berk_signal(3C)
NAME
berksignal, signal - simplified software signal facilities
SYNOPSIS
#define BSDSIGNALFLAVOR
#include <signal.h>
(*signal(sig, func))()
int (*func)();
DESCRIPTION
signal is a simplified interface to the more general sigvec(2)
facility. If you define the _BSD_SIGNAL_FLAVOR macro or only the
_BSD_SOURCE macro when you compile your C application, you will get
the signal functionality described in this entry; otherwise, you will
get the functionality described in signal(2). For more information
on the _BSD_SIGNAL_FLAVOR and _BSD_SOURCE macros, see Porting
Applications to the DG/UX (Trademark) System.
A signal is generated by some abnormal event, initiated by a user at
a terminal (quit, interrupt, stop), by a program error (bus error,
etc.), by request of another program (kill), or when a process is
stopped because it wishes to access its control terminal while in the
background (see termio(7)). Signals are optionally generated when a
process resumes after being stopped, when the status of child
processes changes, or when input is ready at the control terminal.
Most signals cause termination of the receiving process if no action
is taken; some signals instead cause the process receiving them to be
stopped, or are simply discarded if the process has not requested
otherwise. Except for the SIGKILL and SIGSTOP signals, the signal
call allows signals either to be ignored or to cause an interrupt to
a specified location. For a list of the signals, see <sys/signal.h>.
If func is SIG_DFL, the default action for signal sig is reinstated.
If func is SIG_IGN, the signal is subsequently ignored and pending
instances of the signal are discarded. Otherwise, when the signal
occurs, further occurrences of the signal are automatically blocked
and func is called.
A return from the function unblocks the handled signal and continues
the process at the point it was interrupted. Unlike previous signal
facilities, the handler func remains installed after a signal has
been delivered.
If a caught signal occurs during certain system calls, causing the
call to terminate prematurely, the call is automatically restarted.
In particular this can occur during a read(2) or write(2) on a slow
device (such as a terminal; but not a file) and during a wait(2).
The value of signal is the previous (or initial) value of func for
the particular signal.
After a fork(2) or vfork(2) the child inherits all signals.
Execve(2) resets all caught signals to the default action; ignored
signals remain ignored.
Considerations for Threads Programming
+------------+-----------------------------+
| | async- |
|function | reentrant cancel cancel |
| | point safe |
+------------+-----------------------------+
|berksignal | Y N N |
|signal | Y N N |
+------------+-----------------------------+
RETURN VALUE
The previous action is returned on a successful call. Otherwise, -1
is returned and errno is set to indicate the error.
DIAGNOSTICS
signal will fail and no action will take place if one of the
following occur:
EINVAL Sig is not a valid signal number.
EINVAL An attempt is made to ignore or supply a handler for
SIGKILL or SIGSTOP.
EINVAL An attempt is made to ignore SIGCONT (by default
SIGCONT is ignored).
SEE ALSO
kill(1), ptrace(2), kill(2), sigvec(2), sigblock(2), signal(2),
sigsetmask(2), sigpause(2), sigstack(2), reentrant(3), setjmp(3C),
termio(7)
NOTES
signal(3C) provides compatibility with BSD signal handling while
signal(2) is System V based. You can use signal(3C) in either of the
following ways:
1) Define _BSD_SIGNAL_FLAVOR (or define _BSD_SOURCE while not
defining _POSIX_SOURCE or _SYSV3_SOURCE), include <signal.h>,
and call signal(). Calls to signal will translate to
berksignal, which is signal(3C). signal(2) is unavailable with
this method.
2) Include <signal.h> and call berksignal. With this method you
can use both System V signal facilities (call signal to get
signal(2)) and BSD signal facilities (call berksignal to get
signal(3C)).
STANDARDS
When using m88kbcs as the Software Development Environment (SDE)
target, the berksignal function will be an incomplete emulation of
Berkeley semantics. Since we are using BCS system calls, system call
restart is not available. Instead, interrupted system calls will
fail with errno set to EINTR. Also, since this is an emulation
requiring several BCS system calls, a slight performance degradation
may be noticed in comparison to using berksignal in /lib/libc.a.
Licensed material--property of copyright holder(s)