I am working to port a C/Fortran package that was written for POSIX systems to Windows. Most of the Fortran part of the software runs mathematical calculations. The C codes act as interfaces between Fortran and the system. The code is fully console-based and does not have a GUI.
The software is parallelised with MPI, i.e. after launch it runs multiple processes - one master process and several child processes.
Now, one of the hurdles I have faced with porting is the C code that deals with signal. The master process and child processes each have their signal handlers. The way the signal handling is implemented is that, when the master process receives the SIGTERM or SIGSEGV, it sends those to the child processes. In POSIX, that is implemented by kill(pid, SIGTERM)
. The signal handler of the child processes then interact with the Fortran part to gracefully bring the program to an exit.
What would be the best strategy to port this behaviour to Windows? I am not much familiar with Fortran so I would leave the fortran part untouched if I can. The only thing I have to ensure is that somehow the master process communicates with child processes via their PID, then I have enough to start writing code.
I have asked questions about an alternative to kill()
on Windows, and it seems like there is no easy alternative. Please add an answer even if it means I have to modify a lot of code. The C signal code can be seen in another question I asked about this here.
(Please don't mention cygwin or WSL. Cygwin fails to compile it, and I need to run it from Windows, WSL binaries don't work outside of it)