Fortran Library Reference

signal: Change the Action for a Signal

The function is called by:

INTEGER*4 signal or INTEGER*8 signal

n = signal( signum, proc, flag )

signum

INTEGER*4

Input 

Signal number; see signal(3)

proc

Routine name 

Input 

Name of user signal handling routine; must be in an external statement 

flag

INTEGER*4

Input 

flag<0: Use proc as the signal handler

flag>=0: Ignore proc; pass flag as the action:

flag=0: Use the default action

flag=1: Ignore this signal

Return value 

INTEGER*4

Output 

n=-1: System error

n>0: Definition of previous action

n>1: n=Address of routine that would have been called

n<-1: If signum is a valid signal number, then: n=address of routine that would have been called. If signum is a not a valid signal number, then: n is an error number.

 INTEGER*8  On 64-bit environments, signal and the variables receiving its output must be declared INTEGER*8

If proc is called, it is passed the signal number as an integer argument.

If a process incurs a signal, the default action is usually to clean up and abort. A signal handling routine provides the capability of catching specific exceptions or interrupts for special processing.

The returned value can be used in subsequent calls to signal to restore a previous action definition.

You can get a negative return value even though there is no error. In fact, if you pass a valid signal number to signal(), and you get a return value less than -1, then it is OK.

f77 arranges to trap certain signals when a process is started. The only way to restore the default f77 action is to save the returned value from the first call to signal.

f77_floatingpoint.h defines proc values SIGFPE_DEFAULT, SIGFPE_IGNORE, and SIGFPE_ABORT. See "f77_floatingpoint.h: FORTRAN IEEE Definitions"

In 64-bit environments, signal must be declared INTEGER*8, along with the variables receiving its output, to avoid truncation of the address that may be returned.

See also kill(1), signal(3), and kill(3F), and Numerical Computation Guide.