How to set a breakpoint programmatically in Fortran / Raise a SIGINT in Fortran

Viewed 88
1 Answers

Just call the same C system function as in the linked answer

  use iso_c_binding, only: c_int
  
  implicit none

  interface
    function raise(sig) bind(C, name="raise")
      use iso_c_binding, only: c_int
      integer(c_int) :: raise
      integer(c_int), value :: sig
    end function
  end interface

  integer(c_int), parameter :: SIGINT = 2
  
  
  print *, raise(SIGINT)
    
end

It is probably not easy to avoid entering the SIGINT integer value manually. Consult your signal.h or man raise. The value 2 is for POSIX. On POSIX systems you can also use SIGTRAP = 5.

Related