MCPcopy Create free account
hub / github.com/Selectively11/CloudRedirect / DeferredInitThread

Function DeferredInitThread

src/platform/linux/init.cpp:537–576  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

535}
536
537static void* DeferredInitThread(void*)
538{
539 // Poll for steamclient.so -- under LD_PRELOAD we load before Steam has
540 // mapped steamclient, so a fixed delay is insufficient.
541 DebugLog("[CR] DeferredInit: waiting for steamclient.so\n");
542 for (int i = 0; i < 20; i++) { // up to 10 seconds
543 if (SteamclientMapped()) break;
544 usleep(500000);
545 }
546 DebugLog("[CR] DeferredInit: starting\n");
547
548 // Install crash guard so a bad memory read aborts correctly
549 struct sigaction sa = {}, old_segv = {}, old_bus = {};
550 sa.sa_handler = ScanCrashHandler;
551 sigemptyset(&sa.sa_mask);
552 sa.sa_flags = SA_RESETHAND; // Reset to default on signal (async-signal-safe)
553 sigaction(SIGSEGV, &sa, &old_segv);
554 sigaction(SIGBUS, &sa, &old_bus);
555
556 g_inScan = 1;
557 if (sigsetjmp(g_crashJmpBuf, 1) == 0) {
558 DoInit();
559 } else {
560 DebugLog("[CR] DeferredInit: CRASHED during init, aborting safely\n");
561 Log::Error("Caught signal during init - incompatible steamclient? Hooks NOT installed.");
562 Notify("Crashed during init - hooks disabled", true);
563 }
564 g_inScan = 0;
565
566 // Restore original handlers and install crash dump handler if init succeeded
567 sigaction(SIGSEGV, &old_segv, nullptr);
568 sigaction(SIGBUS, &old_bus, nullptr);
569
570 if (g_initialized.load(std::memory_order_acquire)) {
571 InstallCrashDumpHandler();
572 }
573
574 g_initThreadDone.store(true, std::memory_order_release);
575 return nullptr;
576}
577
578
579

Callers

nothing calls this directly

Calls 6

DebugLogFunction · 0.85
SteamclientMappedFunction · 0.85
DoInitFunction · 0.85
NotifyFunction · 0.85
InstallCrashDumpHandlerFunction · 0.85
sigactionClass · 0.70

Tested by

no test coverage detected