mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-07 08:00:21 +02:00
if an application is using `exit` then it is usually a faulting condition rather than cleanly exiting. When cleanly exiting applications will typically use `exit_group` instead. `exit` is useful to quickly cause a single thread to exit in a multi-threaded environment as well, where `exit_group` will take down the entire process group. FEX had implemented this in a way that would do a double Stop signal, cascading to a crash. When tied in to a crash handler, this could get caught in a weird way. This /should/ fix #4198, but I can't confirm locally. It looks like in that issue that the steam install is slightly buggered (as evident by missing srt-logger and steam-runtime-identify-library-abi). This is a bug regardless so fix it and create a unittest. If it doesn't fix the user's bug, then we have another workaround that will definitely solve it.
36 lines
853 B
C++
36 lines
853 B
C++
#include <catch2/catch_test_macros.hpp>
|
|
|
|
#include <unistd.h>
|
|
#include <sys/wait.h>
|
|
#include <sys/syscall.h>
|
|
|
|
TEST_CASE("fork - exit") {
|
|
int child_pid = ::fork();
|
|
if (child_pid == 0) {
|
|
::syscall(SYS_exit, 1);
|
|
// unreachable
|
|
std::terminate();
|
|
} else {
|
|
int status {};
|
|
int exited_child = ::waitpid(child_pid, &status, 0);
|
|
bool exited = WIFEXITED(status);
|
|
REQUIRE(WIFEXITED(status) == 1);
|
|
CHECK(WEXITSTATUS(status) == 1);
|
|
}
|
|
}
|
|
|
|
TEST_CASE("fork - signal") {
|
|
int child_pid = ::fork();
|
|
if (child_pid == 0) {
|
|
::syscall(SYS_tgkill, ::getpid(), ::gettid(), SIGKILL);
|
|
// unreachable
|
|
std::terminate();
|
|
} else {
|
|
int status {};
|
|
int exited_child = ::waitpid(child_pid, &status, 0);
|
|
bool exited = WIFEXITED(status);
|
|
REQUIRE(WIFSIGNALED(status) == 1);
|
|
CHECK(WTERMSIG(status) == SIGKILL);
|
|
}
|
|
}
|