------- Comment #4 from cummings at cacr dot caltech dot edu  2006-09-28 02:00 
-------
Created an attachment (id=12345)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=12345&action=view)
sample code for signal intrinsic function with optional third argument

OK, here is a sample code showing how the signal intrinsic function with an
optional third argument is supposed to work.  The third argument "flag" is an
integer that plays the role of SIG_DFL in the C library version of signal(). 
Quoting from the Absoft Pro Fortran Support Library manual, for example, it
says that when flag=-1, control is passed to the user's signal handler function
"ctrlco" when signal number "signum" is encountered.  If flag=0, the user's
signal handler function is ignored and the default action is taken instead. 
(Presumably this simply calls the C signal function with SIG_DFL instead of the
handler function.)  I think this is the standard way that most Linux Fortran
compilers handle this (PathScale,PGI,Intel,Absoft), so I was surprised that
gfortran does not do this also.  It appears that gfortran simply uses the
second argument as both the signal handler and the flag.  I may have to just
hack around this with a cpp directive or macro, but thought I should point out
the difference from other Linux Fortran compilers.

By the way, please ignore the comments in my original bug report about trying
to pass an argument to the signal handler.  This was incorrect on my part.  The
signal handler is always passed signum by default, I believe.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29240

Reply via email to