berk_signal(3) DG/UX 4.30 berk_signal(3)
NAME
berk_signal, signal - simplified software signal facilities
SYNOPSIS
#define _BSD_SIGNAL_FLAVOR
#include <signal.h>
(*signal(sig, func))()
void (*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/UXTM 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
tty(4)). 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 occurences 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
Licensed material--property of copyright holder(s) Page 1
berk_signal(3) DG/UX 4.30 berk_signal(3)
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.
RETURN VALUE
The previous action is returned on a successful call.
Otherwise, -1 is returned and errno is set to indicate the
error.
ERRORS
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),
setjmp(3), tty(4)
NOTES
Signal(3) provides compatibility with BSD signal handling
while signal(2) is System V based. You can use signal(3) 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 berk_signal, which is signal(3).
signal(2) is unavailable with this method.
2) Include <signal.h> and call berk_signal. With this
method you can use both System V signal facilities
(call signal to get signal(2)) and BSD signal
facilities (call berk_signal to get signal(3)).
STANDARDS
When using m88kbcs as the Software Development Environment
(SDE) target, the berk_signal function will be an incomplete
emulation of Berkeley semantics. Since we are using BCS
system calls, system call restart is not available.
Licensed material--property of copyright holder(s) Page 2
berk_signal(3) DG/UX 4.30 berk_signal(3)
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 berk_signal in
/lib/libc.a.
Licensed material--property of copyright holder(s) Page 3