From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1534) id 817503858414; Tue, 17 Oct 2023 16:24:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 817503858414 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697559875; bh=7EoIAuYgiU7IxIMVWhwsuYX3a++KaRNN+q9c65uEv9s=; h=From:To:Subject:Date:From; b=NrmKdqG2O4JmdGTt1fySzrZpG6JPSAULFj26xHtf4MIOnNfBDvzjWLMHQ8tHMuOsk Rg5fJLti1b1YWpxvHm6rV5nicmiJFLOQuOC+CYu+Hpc6O8vPp8SZmsyM4Er9wwTcQC MWTncTiJeXvSO0QFfYjTdv/DE6azIJlZ6ISD7Br0= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Tobias Burnus To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-4687] fortran/intrinsic.texi: Improve SIGNAL intrinsic entry X-Act-Checkin: gcc X-Git-Author: Tobias Burnus X-Git-Refname: refs/heads/master X-Git-Oldrev: b18d1cabe2f9cccc0cad697e1e0bfd2abebb85f9 X-Git-Newrev: 43c2f85f52c8400b7204e24400c52c3173c50735 Message-Id: <20231017162435.817503858414@sourceware.org> Date: Tue, 17 Oct 2023 16:24:35 +0000 (GMT) List-Id: https://gcc.gnu.org/g:43c2f85f52c8400b7204e24400c52c3173c50735 commit r14-4687-g43c2f85f52c8400b7204e24400c52c3173c50735 Author: Tobias Burnus Date: Tue Oct 17 18:23:09 2023 +0200 fortran/intrinsic.texi: Improve SIGNAL intrinsic entry gcc/fortran/ChangeLog: * intrinsic.texi (signal): Mention that the argument passed to the signal handler procedure is passed by reference. Extend example. Diff: --- gcc/fortran/intrinsic.texi | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi index 6c7ad03a02c7..0db557d5a38c 100644 --- a/gcc/fortran/intrinsic.texi +++ b/gcc/fortran/intrinsic.texi @@ -13168,10 +13168,10 @@ end program test_sign @table @asis @item @emph{Description}: @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine -@var{HANDLER} to be executed with a single integer argument when signal -@var{NUMBER} occurs. If @var{HANDLER} is an integer, it can be used to -turn off handling of signal @var{NUMBER} or revert to its default -action. See @code{signal(2)}. +@var{HANDLER} to be executed with a single integer argument passed by +value when signal @var{NUMBER} occurs. If @var{HANDLER} is an integer, +it can be used to turn off handling of signal @var{NUMBER} or revert to +its default action. See @code{signal(2)}. If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument is supplied, it is set to the value returned by @code{signal(2)}. @@ -13197,19 +13197,25 @@ Subroutine, function @item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar integer. It has @code{INTENT(OUT)}. @end multitable -@c TODO: What should the interface of the handler be? Does it take arguments? @item @emph{Return value}: The @code{SIGNAL} function returns the value returned by @code{signal(2)}. @item @emph{Example}: @smallexample +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 - intrinsic signal - external handler_print - - call signal (12, handler_print) - call signal (10, 1) + use m_handler + 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