mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-22 16:43:05 -05:00
Lines queued behind the logger were lost when the process ended through abort(), std::terminate, the Windows crash report or a guest _Exit, because only driver failure, Driver::stop and a normal exit flushed the queue. libc keeps one end flush (LibcSetEndFlush_nid_no_patch) and runs it from those paths. Its first registration chains a SIGABRT handler in front of the previous one, so every abort() and std::terminate in the process is covered, on Linux as well; with the default disposition the handler restores it and raises again, so raise(SIGABRT) still ends the process. Guest abort() and _Exit, and ReportCrash for the first fatal exception, run the flush directly. AsyncLog registers a bounded flush (FlushFor, 2 s) that polls two counters and takes no lock, so a dying process cannot hang on a blocked stream or on the queue lock; after its first timeout it returns at once. Flush counts queued and finished entries instead of watching the queue and the writer flag, so it waits for the lines queued before the call and not for a moment in which no thread is logging. agc_async_log_fatal runs the test executable as a child that queues lines behind a held stream and ends in abort(), std::terminate(), raise(SIGABRT) (POSIX) or an access violation (Windows), and once more with the stream never released. The lines of the first four must arrive in order, the last child must end after the bound, and every child has a watchdog. agc_async_log gains the bounded flush case.
21 lines
819 B
C++
21 lines
819 B
C++
#ifndef CORE_LIBS_PRX_LIBC_INCLUDE_SHUTDOWN_HPP
|
|
#define CORE_LIBS_PRX_LIBC_INCLUDE_SHUTDOWN_HPP
|
|
|
|
#include <stop_token>
|
|
|
|
class ProcessShutdown final {};
|
|
|
|
extern "C" void LibcRegisterShutdown_nid_postfix(void (*callback)());
|
|
extern "C" void LibcRunShutdown_nid_postfix();
|
|
extern "C" std::stop_token LibcShutdownToken_nid_postfix();
|
|
extern "C" void LibcRequestShutdown_nid_postfix();
|
|
extern "C" void LibcRequestExit_nid_postfix(int code);
|
|
extern "C" [[noreturn]] void LibcAwaitExit_nid_postfix();
|
|
extern "C" [[noreturn]] void LibcExit_nid_no_patch(int code);
|
|
extern "C" [[noreturn]] void LibcExitWithoutHandlers_nid_no_patch(int code);
|
|
extern "C" [[noreturn]] void LibcTerminate_nid_no_patch(int code);
|
|
extern "C" void LibcSetEndFlush_nid_no_patch(void (*flush)());
|
|
extern "C" void LibcRunEndFlush_nid_no_patch();
|
|
|
|
#endif
|