HP C/iX Library Reference Manual (30026-90004)
Chapter 5 311
HP C/iX Library Function Descriptions
signal
signal
Specifies how a signal is to be handled.
Syntax
#include <signal.h>
void (*signal (int
sig
, void (*
func
)(int)))(int);
Parameters
sig
A signal number.
func
A pointer to the function that performs the exception handling.
Return Values
x If successful, the most recent value of
func
.
SIG_ERR An error occurred; errno is set to a positive value.
Description
The signal function defines the actions to take when the specified signal is raised. The
action can be one of the following:
• Take the default action of terminating the program with some message.
• Ignore the signal.
• Invoke the user-defined signal handling function.
The signal function accepts two arguments: a signal number ("sig"), and a second
argument (of type pointer to function accepting an int) that defines an action to take when
a signal is raised.
You can define your own signal numbers in addition to using any of the predefined signal
names listed below:
SIGABRT Abnormal termination, (for example, by the abort function).
SIGFPE An erroneous arithmetic operation, (for example, divide by 0).
SIGILL An illegal instruction was executed (possibly after a jump).
SIGINT An interactive interrupt signal was received.
SIGSEGV An invalid access to storage.
SIGTERM A termination request was sent to the program.
The second parameter,
func
, is a pointer to a function accepting an int. The
func
parameter defines the action to be taken upon receipt of the signal specified in
sig
.
In addition to passing the name of a user signal handler, you can use the following
predefined macro values as the
func
parameter. The macros expand to constant