8.248 SIGNAL — Signal handling subroutine (or function)
- Description:
-
SIGNAL(NUMBER, HANDLER [, STATUS])causes external subroutine HANDLER to be executed with a single integer argument passed by value 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. Seesignal(2).If
SIGNALis called as a subroutine and the STATUS argument is supplied, it is set to the value returned bysignal(2). - Standard:
-
GNU extension
- Class:
-
Subroutine, function
- Syntax:
-
CALL SIGNAL(NUMBER, HANDLER [, STATUS])STATUS = SIGNAL(NUMBER, HANDLER) - Arguments:
-
NUMBER Shall be a scalar integer, with INTENT(IN)HANDLER Signal handler ( INTEGER FUNCTIONorSUBROUTINE) or dummy/globalINTEGERscalar.INTEGER. It isINTENT(IN).STATUS (Optional) STATUS shall be a scalar integer. It has INTENT(OUT). - Return value:
-
The
SIGNALfunction returns the value returned bysignal(2). - Example:
-
module m_handler contains ! POSIX.1-2017: void (*func)(int) subroutine handler_print(signum) bind(C) use iso_c_binding, only: c_int integer(c_int), value :: signum print *, 'handler_print invoked with signum =', signum end subroutine end module program test_signal use m_handler intrinsic :: signal, sleep call signal (12, handler_print) ! 12 = SIGUSR2 (on some systems) call signal (10, 1) ! 10 = SIGUSR1 and 1 = SIG_IGN (on some systems) call sleep (30) end program test_signal
© Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gfortran/SIGNAL.html