BetterC + Windows + setjmp longjmp
Diederik de Groot
ddegroot at talon.nl
Tue Sep 18 00:12:35 UTC 2018
On Monday, 17 September 2018 at 23:44:41 UTC, SrMordred wrote:
> Its possible to use setjmp/longjmp on windows?
> Or, to be straight to my problem: its possible to continue
> execution after a SIGSEGV(or any other failure/signal) with
> betterC and windows?
You can use core.stdc.signal
nothrow @nogc @system sigfn_t signal(SIGSEGV, sigfn_t func)
To catch the signal
With a handler signature of:
enum void function(int) nothrow @nogc @system SIG_ERR;
However continuing execution after catching a SIGSEGV is normally
considered undefined (at least to POSIX).
Quote:
According to POSIX, the behavior of a process is undefined after
it ignores a SIGFPE, SIGILL, or SIGSEGV signal that was not
generated by kill(2) or raise(3). Integer division by zero has
undefined result. On some architectures it will generate a SIGFPE
signal. (Also dividing the most negative integer by -1 may
generate SIGFPE.) Ignoring this signal might lead to an endless
loop.
From:
https://stackoverflow.com/questions/14233464/can-a-c-program-continue-execution-after-a-signal-is-handled#14233912
I am not sure if this is any different on Windows. They handle
SIGSEGV differently (ie: as an exception). You would have to read
the windows manual, try and test (heavily).
More information about the Digitalmars-d-learn
mailing list