@@ -245,15 +245,30 @@ extension ExitTest {
245
245
#if os(Windows)
246
246
// Windows does not support signal handling to the degree UNIX-like systems
247
247
// do. When a signal is raised in a Windows process, the default signal
248
- // handler simply calls `exit ()` and passes the constant value `3`. To allow
249
- // us to handle signals on Windows, we install signal handlers for all
248
+ // handler simply calls `_exit ()` and passes the constant value `3`. To
249
+ // allow us to handle signals on Windows, we install signal handlers for all
250
250
// signals supported on Windows. These signal handlers exit with a specific
251
251
// exit code that is unlikely to be encountered "in the wild" and which
252
252
// encodes the caught signal. Corresponding code in the parent process looks
253
253
// for these special exit codes and translates them back to signals.
254
+ //
255
+ // Microsoft's documentation for `_Exit()` and `_exit()` indicates they
256
+ // behave identically. Their documentation for abort() can be found at
257
+ // https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/abort?view=msvc-170
258
+ // and states: "[...] abort calls _exit to terminate the process with exit
259
+ // code 3 [...]".
260
+ //
261
+ // The Wine project's implementation of raise() calls `_exit(3)` by default.
262
+ // See https://github.com/wine-mirror/wine/blob/master/dlls/msvcrt/except.c
263
+ //
264
+ // Finally, an official copy of the UCRT sources (not up to date) is hosted
265
+ // at https://www.nuget.org/packages/Microsoft.Windows.SDK.CRTSource . That
266
+ // repository doesn't have an official GitHub mirror, but you can manually
267
+ // navigate to misc/signal.cpp:481 to see the implementation of SIG_DFL
268
+ // (which, again, calls `_exit(3)` unconditionally.)
254
269
for sig in [ SIGINT, SIGILL, SIGFPE, SIGSEGV, SIGTERM, SIGBREAK, SIGABRT, SIGABRT_COMPAT] {
255
270
_ = signal ( sig) { sig in
256
- _Exit ( STATUS_SIGNAL_CAUGHT_BITS | sig)
271
+ _exit ( STATUS_SIGNAL_CAUGHT_BITS | sig)
257
272
}
258
273
}
259
274
#endif
0 commit comments