Next: , Previous: Sign Intrinsic, Up: Table of Intrinsic Functions


8.11.9.228 Signal Intrinsic (subroutine)

     CALL Signal(Number, Handler, Status)

Number: INTEGER; scalar; INTENT(IN).

Handler: Signal handler (INTEGER FUNCTION or SUBROUTINE) or dummy/global INTEGER(KIND=1) scalar.

Status: INTEGER(KIND=7); OPTIONAL; scalar; INTENT(OUT).

Intrinsic groups: unix.

Description:

If Handler is a an EXTERNAL routine, arranges for it to be invoked with a single integer argument (of system-dependent length) when signal Number occurs. If Handler is an integer, it can be used to turn off handling of signal Number or revert to its default action. See signal(2).

Note that Handler will be called using C conventions, so the value of its argument in Fortran terms Fortran terms is obtained by applying %LOC() (or LOC()) to it.

The value returned by signal(2) is written to Status, if that argument is supplied. Otherwise the return value is ignored.

Some non-GNU implementations of Fortran provide this intrinsic as only a function, not as a subroutine, or do not support the (optional) Status argument.

Warning: Use of the libf2c run-time library function `signal_' directly (such as via `EXTERNAL SIGNAL') requires use of the %VAL() construct to pass an INTEGER value (such as `SIG_IGN' or `SIG_DFL') for the Handler argument.

However, while `CALL SIGNAL(signum, %VAL(SIG_IGN))' works when `SIGNAL' is treated as an external procedure (and resolves, at link time, to libf2c's `signal_' routine), this construct is not valid when `SIGNAL' is recognized as the intrinsic of that name.

Therefore, for maximum portability and reliability, code such references to the `SIGNAL' facility as follows:

     INTRINSIC SIGNAL
     ...
     CALL SIGNAL(signum, SIG_IGN)

g77 will compile such a call correctly, while other compilers will generally either do so as well or reject the `INTRINSIC SIGNAL' statement via a diagnostic, allowing you to take appropriate action.

For information on other intrinsics with the same name: See Signal Intrinsic (function).