{"record":{"id":"f16eeacb411249df","repo":"tinyhumansai/openhuman","slug":"failed-to-install-sigterm-handler","errorCode":null,"errorMessage":"failed to install SIGTERM handler","messagePattern":"failed to install SIGTERM handler","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/core/shutdown.rs","lineNumber":82,"sourceCode":"/// fail rustdoc.)\npub async fn signal() {\n    // Wait for the OS to send a termination signal.\n    wait_for_signal().await;\n    log::info!(\"[core] shutdown signal received, cleaning up background services\");\n    // Once received, run all registered cleanup tasks.\n    run_hooks().await;\n    log::info!(\"[core] all shutdown hooks completed\");\n}\n\n/// Wait for either SIGINT (Ctrl-C) or SIGTERM (Unix termination signal).\n///\n/// This uses `tokio::signal` to asynchronously wait for these events.\nasync fn wait_for_signal() {\n    #[cfg(unix)]\n    {\n        use tokio::signal::unix::{signal, SignalKind};\n        let mut sigterm =\n            signal(SignalKind::terminate()).expect(\"failed to install SIGTERM handler\");\n        tokio::select! {\n            _ = tokio::signal::ctrl_c() => {\n                log::info!(\"[core] received SIGINT (Ctrl-C)\");\n            }\n            _ = sigterm.recv() => {\n                log::info!(\"[core] received SIGTERM\");\n            }\n        }\n    }\n\n    #[cfg(not(unix))]\n    {\n        // On non-Unix platforms (like Windows), we only listen for Ctrl-C.\n        let _ = tokio::signal::ctrl_c().await;\n        log::info!(\"[core] received SIGINT (Ctrl-C)\");\n    }\n}\n","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/src/core/shutdown.rs#L64-L100","documentation":"Panic payload when tokio::signal::unix::signal(SignalKind::terminate()) fails during wait_for_signal(): installing the SIGTERM handler can fail if the runtime lacks signal-driver support or the process environment forbids it. The expect aborts the shutdown waiter, so the process loses graceful SIGTERM handling.","triggerScenarios":"Thrown at src/core/shutdown.rs:82 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure shutdown::signal() runs on a tokio runtime with signal support enabled (not a current-thread runtime without the IO driver)","Register the handler before entering any code that masks SIGTERM","Fall back to catching SIGINT only or a plain ctrl_c() stream when SIGTERM registration fails"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}