Copyright (C) 2000-2012 |
GNU Info (g77-295.info)Signal Intrinsic (function)Signal Intrinsic (function) ........................... Signal(NUMBER, HANDLER) Signal: `INTEGER(KIND=7)' function. NUMBER: `INTEGER'; scalar; INTENT(IN). HANDLER: Signal handler (`INTEGER FUNCTION' or `SUBROUTINE') or dummy/global `INTEGER(KIND=1)' scalar. Intrinsic groups: `badu77'. 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 is obtained by applying `%LOC()' (or LOC()) to it. The value returned by `signal(2)' is returned. Due to the side effects performed by this intrinsic, the function form is not recommended. *Warning:* If the returned value is stored in an `INTEGER(KIND=1)' (default `INTEGER') argument, truncation of the original return value occurs on some systems (such as Alphas, which have 64-bit pointers but 32-bit default integers), with no warning issued by `g77' under normal circumstances. Therefore, the following code fragment might silently fail on some systems: INTEGER RTN EXTERNAL MYHNDL RTN = SIGNAL(SIGNUM, MYHNDL) ... ! Restore original handler: RTN = SIGNAL(SIGNUM, RTN) The reason for the failure is that `RTN' might not hold all the information on the original handler for the signal, thus restoring an invalid handler. This bug could manifest itself as a spurious run-time failure at an arbitrary point later during the program's execution, for example. *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 `RTN = 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 ... RTN = 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: Note: Signal Intrinsic (subroutine). automatically generated by info2www version 1.2.2.9 |