I'm trying to set a default behaviour for threads when they encounter a specific signal that I have set. In all the reference code I have found they use SIGUSR1/2 which is not defined for windows and they use functions like sigemptyset()
and sigaction()
. I know that windows has a signal()
function for the same functionality in windows but still there is another problem of what signal to use as they dont provide any extra or signals that are not in use but only the important or essential ones that are necessary for the code running. So I am asking if there is anyway to define our own signals like SIGUSR in windows ourselves?
I'm currently using mingw-w64ucrt for more info
Do not rely on signal
for cross-platform code.
It is much easier (and more reliable) to just do two sets of source code - signal catching for linux and event handling for windows. Put these sets in different directories and/or sub-libraries and choose one or another in makefile.
Start by reading here: https://learn.microsoft.com/en-us/previous-versions/ms811896(v=msdn.10)#signals-and-signal-handling It even has a nice table to describe how each individual signal should be replaced on windows.