Sun Studio 12: Fortran Library Reference

1.4.46 signal: Change the Action for a Signal

The function is called by:

INTEGER*4 signal or INTEGER*8 signal

n = signal( signum, proc, flag )




Signal number; see signal(3)


Routine name 


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




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 



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.




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.

floatingpoint.h defines proc values SIGFPE_DEFAULT, SIGFPE_IGNORE, and SIGFPE_ABORT. See 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.