Open ivan-pi opened 3 years ago
Reply from @awvwgk: https://github.com/fortran-lang/stdlib/issues/308#issuecomment-776624029
From my experience the
signal
extension ingfortran
andifort
is not really satisfactory, therefore I usually resort to install signal handlers via C. I use it to gracefully catch SIGINT and SIGTERM and shut down the program, depending on your compiler those are most likely completely ignored by default which makes it a pain to kill a Fortran program.
The tutorial by @interkosmos contains a small section on signals also demonstrating the approach using C: https://cyber.dabamos.de/programming/modernfortran/inter-process-communication.html#signals
Perhaps a derived type similar to the boost::asio::signal_set would be suitable for Fortran. This should also work under Windows.
I found a document which describes signal handling in Fortran: https://www.sharcnet.ca/help/images/4/42/Fortran_Signal_Handling.pdf
Some compilers already provide extensions, in
gfortran
the subroutinesignal
is available.Originally posted by @ivan-pi in https://github.com/fortran-lang/stdlib/issues/308#issuecomment-776620922