sigset(2) CLIX sigset(2)
NAME
sigset, sighold, sigrelse, sigignore, sigpause - Signal management
functions
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
#include <signal.h>
void ((*sigset)(
int sig ,
void (*func) (void)) );
int sighold(
int sig );
int sigrelse(
int sig );
int sigignore(
int sig );
int sigpause(
int sig );
PARAMETERS
sig Specifies the target signal number.
func Specifies the address of a user function which will be invoked when
the specified signal is received by the process, or a special value
indicating that the signal should be ignored or handled by the
system in the default manner.
DESCRIPTION
These functions provide signal management for application processes. The
sigset() function specifies the system signal action to be taken when
signal sig is received. This action is either calling a process signal-
catching handler func or performing a system-defined action.
The sig parameter can be assigned any one of the following values except
SIGKILL or SIGSTOP. Machine- or implementation-dependent signals are not
included. (See NOTES below.) Each value of sig is a macro, defined in
<signal.h>, that expands to an integer constant expression.
SIGHUP hangup
2/94 - Intergraph Corporation 1
sigset(2) CLIX sigset(2)
SIGINT interrupt
SIGQUIT* quit
SIGILL* illegal instruction (not held when caught)
SIGTRAP* trace trap (not held when caught)
SIGABRT* abort
SIGFPE* floating-point exception
SIGKILL kill (cannot be caught or ignored)
SIGSYS* bad argument to function
SIGPIPE write on a pipe with no one to read it
SIGALRM alarm clock
SIGTERM software termination signal
SIGUSR1 user-defined signal 1
SIGUSR2 user-defined signal 2
SIGCLD & SIGCHLD death of a child or child has stopped (see CAUTIONS below)
SIGPWR power fail (see CAUTIONS below)
SIGURG urgent condition present on socket (see NOTES below)
SIGIO I/O is possible on a socket (see NOTES below)
SIGPOLL selectable event is pending (see NOTES below)
SIGSTOP stop (cannot be caught or ignored)
SIGTSTP stop signal generated from keyboard
SIGTTIN background read attempted from control terminal
SIGTTOU background write attempted from control terminal
SIGCONT continue if stopped (cannot be ignored)
The description of SIG_DFL (below) explains asterisks (*) in the above
list.
The following values for the system-defined actions of func are also
defined in <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.
SIG_DFL Default system action. If SIG_DFL is assigned for the SIGTSTP,
SIGTTIN, or SIGTTOU signals, the process will enter the stopped
state until a SIGCONT or SIGKILL signal is received. If
SIG_DFL is assigned for the SIGCONT signal and the process has
entered the stopped state by receiving a stop signal (SIGSTOP,
SIGTSTP, SIGTTIN or SIGTTOU), the process returns to its prior
state.
Otherwise, upon receipt of the sig signal, the receiving
process is to be terminated with all of the consequences
outlined in the exit() function. In addition, a core image
will be made in the current working directory of the receiving
process if an asterisk appears with sig in the above list and
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
2 Intergraph Corporation - 2/94
sigset(2) CLIX sigset(2)
created. If the file must be created, it will have the
following properties:
-- A mode of 0666 modified by the file creation mask. (See
the umask() function).
-- 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.
SIG_IGN Ignore the signal. Any pending signal sig is discarded and the
system signal action is set to ignore future occurrences of
this signal type.
SIG_HOLD Hold the signal. The signal sig is to be held when it is
received. Any pending signal of this type remains held. Only
one signal of each type is held.
Otherwise, func must be a pointer to a function, the signal-catching
handler, that is to be called when signal sig occurs. In this case,
sigset() specifies that the process will call this function when it
receives signal sig. Any pending signal of this type is released. This
handler address is retained across calls to the other signal management
functions listed here.
When a signal occurs, the signal number sig will be passed as the only
argument to the signal-catching handler. Before calling the signal-
catching handler, the system signal action will be set to SIG_HOLD.
During normal return from the signal-catching handler, the system signal
action is restored to func and any held signal of this type released. If
a nonlocal goto (longjmp) is taken, sigrelse() must be called to restore
the system signal action and release any held signal of this type.
In general, upon return from the signal-catching handler, the receiving
process resumes execution where it was interrupted. However, when a
signal is caught during any of the following:
⊕ A read(), write(), or open() function,
⊕ A ioctl() function during a sigpause() function,
⊕ A wait() function that does not return immediately, due to a previously
stopped or zombie process,
⊕ Any other call that may sleep in the kernel,
the signal-catching handler will be executed and then the interrupted
function may return a -1 to the calling process with errno set to EINTR.
2/94 - Intergraph Corporation 3
sigset(2) CLIX sigset(2)
The sighold() and sigrelse() functions are used to establish critical
regions of code. The sighold() function is analogous to raising the
priority level and deferring or holding a signal until the priority is
lowered by sigrelse(). The sigrelse() function restores the system signal
action to that specified previously by sigset().
The sigignore() function sets the action for signal sig to SIG_IGN. (See
above.)
The sigpause() function suspends the calling process until it receives a
signal, the same as pause(). However, if the signal sig had been received
and held, it is released and the system signal action taken. This
function is useful for testing variables changed on the occurrence of a
signal. The correct usage is to use sighold() to block the signal first,
and then test the variables. If they have not changed, call sigpause() to
wait for the signal.
EXAMPLES
1. To request that the user function sigcld_hdlr be invoked when the
calling process receives a SIGCLD signal:
if (sigset(SIGCLD, sigcld_hdlr) == -1)
perror("Sigset for SIGCLD failed");
2. To prevent processing of a SIGUSR1 while executing some critical
section of code:
sighold(SIGUSR1);
...
sigrelse(SIGUSR1);
NOTES
The SIGPOLL signal is issued when a file descriptor corresponding to a
STREAMS (see the intro() function) file has a selectable event pending. A
process must specifically request that this signal be sent using the
I_SETSIG ioctl() call. (See the streamio file.) Otherwise, the process
will never receive SIGPOLL.
For portability, applications should use only the symbolic names of
signals rather than their values and use only the set of signals defined
here. The action for the signals SIGKILL and SIGSTOP cannot be changed
from the default system action.
Specific implementations may have other implementation-defined signals.
Also, additional implementation-defined arguments may be passed to the
signal-catching handler for hardware-generated signals. For certain
hardware-generated signals, it may not be possible to resume execution at
4 Intergraph Corporation - 2/94
sigset(2) CLIX sigset(2)
the point of interruption.
The SIG_IGN signal is the default value for the SIGIO and SIGURG signals.
The signal type SIGSEGV is reserved for the condition that occurs on an
invalid access to a data object. If an implementation can detect this
condition, this signal type should be used.
The other signal management functions, signal() and pause(), should not be
used for a particular signal type with these functions.
CAUTIONS
Three signals that behave differently than the signals described above
exist in this release of the system:
SIGCLD Death of a child (reset when caught).
SIGCHLD Death of a child (reset when caught).
SIGPWR Power failure (not reset when caught).
For these signals, func is assigned one of three values: SIG_DFL,
SIG_IGN, or a function address. The actions prescribed by these values
are as follows:
SIG_DFL
Ignore signal.
SIG_IGN
Ignore signal. Also, if sig is SIGCLD, the calling process's child
processes do not create zombie processes when they terminate. (See
exit().)
function address
Catch signal. If the signal is SIGPWR, 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 received SIGCLD signals will be ignored. (This is
the default action.)
The SIGCLD signal also affects the two functions wait() and exit() in the
following ways:
wait() If the func value of SIGCLD is set to SIG_IGN and a wait() is
executed, the wait() will block until all of the calling
process's child processes terminate; it then returns a value of
-1 with errno set to ECHILD.
exit() If in the exiting process's parent process the func value of
2/94 - Intergraph Corporation 5
sigset(2) CLIX sigset(2)
SIGCLD is set to SIG_IGN, 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 preceding processes. A process
that may be piped into in this manner (and thus become the parent
of other processes) should not set SIGCLD to be caught.
RETURN VALUES
Upon successful completion, sigset() returns the previous value of the
system signal action for the specified signal sig. Otherwise, a value of
SIG_ERR is returned and errno is set to indicate the error. The SIG_ERR
signal is defined in <signal.h>.
For the other functions, upon successful completion, a value of 0 is
returned. Otherwise, a value of -1 is returned and errno is set to
indicate the error.
ERRORS
The sigset() function fails if one or more of the following is true:
[EINVAL] The sig parameter is an illegal signal number (including
SIGKILL or SIGSTOP) or the default handling of sig cannot be
changed.
[EINTR] A signal was caught during the sigpause() function.
The sighold(), sigrelse(), sigignore(), and sigpause() functions all set
errno to EINVAL when sig is an illegal signal number (including SIGKILL
and SIGSTOP).
RELATED INFORMATION
Functions: signal(2), sigcld(2), wait2(2), kill(2), pause(2), setjmp(3),
wait(2)
6 Intergraph Corporation - 2/94