{"record":{"id":"d9ef3fb78d29ef39","repo":"sigoden/dufs","slug":"failed-to-install-ctrl-c-signal-handler","errorCode":null,"errorMessage":"Failed to install CTRL+C signal handler","messagePattern":"Failed to install CTRL\\+C signal handler","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/main.rs","lineNumber":308,"sourceCode":"\n    if urls.len() == 1 {\n        output.push_str(&format!(\"Listening on {}\", urls[0]))\n    } else {\n        let info = urls\n            .iter()\n            .map(|v| format!(\"  {v}\"))\n            .collect::<Vec<String>>()\n            .join(\"\\n\");\n        output.push_str(&format!(\"Listening on:\\n{info}\\n\"))\n    }\n\n    Ok(output)\n}\n\nasync fn shutdown_signal() {\n    tokio::signal::ctrl_c()\n        .await\n        .expect(\"Failed to install CTRL+C signal handler\")\n}\n","sourceCodeStart":290,"sourceCodeEnd":310,"githubUrl":"https://github.com/sigoden/dufs/blob/fe7fd564f80dfbac361c8e0589c3845638149d38/src/main.rs#L290-L310","documentation":"`shutdown_signal` awaits tokio's CTRL+C handler; if the runtime fails to register the SIGINT handler, the code panics via `.expect` with this message. This is a fatal startup/runtime condition, not a request error — tokio::signal can fail when signal handling is unavailable in the environment.","triggerScenarios":"Running on a platform/environment where SIGINT handling cannot be installed (unsupported platform, restricted sandbox, signal dispositions blocked by the container runtime).","commonSituations":"Minimal containers without signal support; running under restrictive seccomp profiles; exotic/embedded targets unsupported by tokio's signal driver.","solutions":["Run on a supported platform (Linux/macOS/Windows) with standard signal support.","Check container/sandbox security profiles that block sigaction/signal syscalls.","Upgrade tokio to a version supporting the target platform.","Wrap shutdown in an alternative (e.g. poll a flag file) if signals are inherently unavailable."],"exampleFix":"// before\nasync fn shutdown_signal() {\n    tokio::signal::ctrl_c().await.expect(\"Failed to install CTRL+C signal handler\")\n}\n// after\nasync fn shutdown_signal() {\n    if tokio::signal::ctrl_c().await.is_err() {\n        eprintln!(\"ctrl_c unavailable; falling back\");\n        std::future::pending::<()>().await;\n    }\n}","handlingStrategy":"fallback","validationCode":"#[cfg(unix)]\nfn signals_supported() -> bool { true } // else check target support before relying on ctrl_c","typeGuard":null,"tryCatchPattern":"tokio::select! { _ = tokio::signal::ctrl_c() => {}, _ = manual_shutdown_watch() => {} }","preventionTips":["Avoid sandboxes/seccomp profiles that block signal syscalls","Pin a tokio version that supports your target platform","Provide a non-signal shutdown path (admin endpoint/flag file)","Test container images for graceful Ctrl+C shutdown"],"tags":["rust","signal-handling","tokio","panic"],"backgroundTag":"unsupported-platform","analyzedSha":"fe7fd564f80dfbac361c8e0589c3845638149d38","analyzedAt":"2026-09-09T13:01:22.843Z","contentChangedAt":"2026-09-09T13:01:22.843Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}