upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/shims/process.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/shims/process.cpp')
-rw-r--r--runtime/shims/process.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/runtime/shims/process.cpp b/runtime/shims/process.cpp
index 1fc4fee7f..0977f5298 100644
--- a/runtime/shims/process.cpp
+++ b/runtime/shims/process.cpp
@@ -16,6 +16,7 @@
16#include <windows.h> 16#include <windows.h>
17 17
18#include <atomic> 18#include <atomic>
19#include <csignal>
19#include <cstdio> 20#include <cstdio>
20#include <cstdlib> 21#include <cstdlib>
21#include <cstring> 22#include <cstring>
@@ -89,6 +90,15 @@ void __cdecl game_exit(int code) { end_run(code); }
89void __stdcall game_exit_process(UINT code) { end_run(static_cast<int>(code)); } 90void __stdcall game_exit_process(UINT code) { end_run(static_cast<int>(code)); }
90void __cdecl game_abort() { 91void __cdecl game_abort() {
91 std::fprintf(stderr, "[rt] process: the game called abort()\n"); 92 std::fprintf(stderr, "[rt] process: the game called abort()\n");
93 // The game's signal() import is not shimmed: its handler goes into the host CRT's process-wide table, which
94 // std::signal here reads too. UCRT's abort() raises SIGABRT before it terminates; do the same only when a
95 // handler is installed, because raising it with the default action would terminate the host process. A handler
96 // that exits ends the run itself; one that returns falls through to the CRT's abort code below.
97 const auto previous = std::signal(SIGABRT, SIG_DFL);
98 if (previous != SIG_ERR) {
99 std::signal(SIGABRT, previous);
100 if (previous != SIG_DFL && previous != SIG_IGN) std::raise(SIGABRT);
101 }
92 end_run(3); // the CRT's abort exit code 102 end_run(3); // the CRT's abort exit code
93} 103}
94 104