diff --git a/rpcsx-os/main.cpp b/rpcsx-os/main.cpp index 8c74375fb..37d7db9e0 100644 --- a/rpcsx-os/main.cpp +++ b/rpcsx-os/main.cpp @@ -84,6 +84,22 @@ handle_signal(int sig, siginfo_t *info, void *ucontext) { } static void setupSigHandlers() { + stack_t ss; + + ss.ss_sp = malloc(SIGSTKSZ); + if (ss.ss_sp == NULL) { + perror("malloc"); + exit(EXIT_FAILURE); + } + + ss.ss_size = SIGSTKSZ; + ss.ss_flags = 0; + + if (sigaltstack(&ss, NULL) == -1) { + perror("sigaltstack"); + exit(EXIT_FAILURE); + } + struct sigaction act {}; act.sa_sigaction = handle_signal; act.sa_flags = SA_SIGINFO | SA_ONSTACK; diff --git a/rpcsx-os/ops.cpp b/rpcsx-os/ops.cpp index d672ca62b..099a420c1 100644 --- a/rpcsx-os/ops.cpp +++ b/rpcsx-os/ops.cpp @@ -10,6 +10,7 @@ #include "vfs.hpp" #include "vm.hpp" #include +#include #include #include #include @@ -470,6 +471,22 @@ SysResult thr_new(orbis::Thread *thread, orbis::ptr param, std::printf("Starting child thread %lu\n", (long)(proc->pid + baseId)); std::thread{[=, childThread = Ref(childThread)] { + stack_t ss; + + ss.ss_sp = malloc(SIGSTKSZ); + if (ss.ss_sp == NULL) { + perror("malloc"); + exit(EXIT_FAILURE); + } + + ss.ss_size = SIGSTKSZ; + ss.ss_flags = 0; + + if (sigaltstack(&ss, NULL) == -1) { + perror("sigaltstack"); + exit(EXIT_FAILURE); + } + static_cast( uwrite(_param.child_tid, slong(childThread->tid))); // TODO: verify auto context = new ucontext_t{}; diff --git a/rpcsx-os/thread.cpp b/rpcsx-os/thread.cpp index 722c248fa..9142e85aa 100644 --- a/rpcsx-os/thread.cpp +++ b/rpcsx-os/thread.cpp @@ -43,22 +43,6 @@ void rx::thread::deinitialize() {} void rx::thread::invoke(orbis::Thread *thread) { g_current = thread; - stack_t ss; - - ss.ss_sp = malloc(SIGSTKSZ); - if (ss.ss_sp == NULL) { - perror("malloc"); - exit(EXIT_FAILURE); - } - - ss.ss_size = SIGSTKSZ; - ss.ss_flags = 0; - - if (sigaltstack(&ss, NULL) == -1) { - perror("sigaltstack"); - exit(EXIT_FAILURE); - } - sigset_t unblockSigs{}; sigset_t oldSigmask{}; sigaddset(&unblockSigs, SIGSYS);