diff --git a/rpcsx-os/backtrace.cpp b/rpcsx-os/backtrace.cpp index 7b8d33df5..a6e8ad5c8 100644 --- a/rpcsx-os/backtrace.cpp +++ b/rpcsx-os/backtrace.cpp @@ -77,11 +77,12 @@ void rx::printStackTrace(ucontext_t *context, orbis::Thread *thread, unw_cursor_t cursor; char buffer[1024]; - + flockfile(stderr); if (int r = unw_init_local2(&cursor, context, UNW_INIT_SIGNAL_FRAME)) { int len = snprintf(buffer, sizeof(buffer), "unw_init_local: %s\n", unw_strerror(r)); write(fileno, buffer, len); + funlockfile(stderr); return; } @@ -123,4 +124,5 @@ void rx::printStackTrace(ucontext_t *context, orbis::Thread *thread, write(fileno, buffer, offset); count++; } while (unw_step(&cursor) > 0 && count < 32); + funlockfile(stderr); } diff --git a/rpcsx-os/main.cpp b/rpcsx-os/main.cpp index 475bc195f..70a30d255 100644 --- a/rpcsx-os/main.cpp +++ b/rpcsx-os/main.cpp @@ -178,6 +178,7 @@ static void onSysEnter(orbis::Thread *thread, int id, uint64_t *args, if (true || !g_traceSyscalls) { return; } + flockfile(stdout); std::printf(" [%u] ", thread->tid); if (auto name = getSyscallName(thread, id)) { @@ -195,6 +196,7 @@ static void onSysEnter(orbis::Thread *thread, int id, uint64_t *args, } std::printf(")\n"); + funlockfile(stdout); } static void onSysExit(orbis::Thread *thread, int id, uint64_t *args, @@ -203,6 +205,7 @@ static void onSysExit(orbis::Thread *thread, int id, uint64_t *args, return; } + flockfile(stdout); std::printf("%c: [%u] ", result.isError() ? 'E' : 'S', thread->tid); if (auto name = getSyscallName(thread, id)) { @@ -221,6 +224,7 @@ static void onSysExit(orbis::Thread *thread, int id, uint64_t *args, std::printf(") -> Status %d, Value %lx:%lx\n", result.value(), thread->retval[0], thread->retval[1]); + funlockfile(stdout); } static int ps4Exec(orbis::Process *mainProcess,