{"record":{"id":"4f84a20afd541dd3","repo":"vectordotdev/vector","slug":"failed-to-set-up-sighup-handler","errorCode":null,"errorMessage":"Failed to set up SIGHUP handler.","messagePattern":"Failed to set up SIGHUP handler\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/signal.rs","lineNumber":200,"sourceCode":"        for shutdown_tx in self.shutdown_txs.drain(..) {\n            // An error just means the channel was already shut down; safe to ignore.\n            _ = shutdown_tx.send(());\n        }\n    }\n}\n\n/// Signals from OS/user.\n#[cfg(unix)]\nfn os_signals(runtime: &Runtime) -> impl Stream<Item = SignalTo> + use<> {\n    use tokio::signal::unix::{SignalKind, signal};\n\n    // The `signal` function must be run within the context of a Tokio runtime.\n    runtime.block_on(async {\n        let mut sigint = signal(SignalKind::interrupt()).expect(\"Failed to set up SIGINT handler.\");\n        let mut sigterm =\n            signal(SignalKind::terminate()).expect(\"Failed to set up SIGTERM handler.\");\n        let mut sigquit = signal(SignalKind::quit()).expect(\"Failed to set up SIGQUIT handler.\");\n        let mut sighup = signal(SignalKind::hangup()).expect(\"Failed to set up SIGHUP handler.\");\n\n        async_stream::stream! {\n            loop {\n                let signal = tokio::select! {\n                    _ = sigint.recv() => {\n                        info!(message = \"Signal received.\", signal = \"SIGINT\");\n                        SignalTo::Shutdown(None)\n                    },\n                    _ = sigterm.recv() => {\n                        info!(message = \"Signal received.\", signal = \"SIGTERM\");\n                        SignalTo::Shutdown(None)\n                    } ,\n                    _ = sigquit.recv() => {\n                        info!(message = \"Signal received.\", signal = \"SIGQUIT\");\n                        SignalTo::Quit\n                    },\n                    _ = sighup.recv() => {\n                        info!(message = \"Signal received.\", signal = \"SIGHUP\");","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/src/signal.rs#L182-L218","documentation":"Vector installs async signal handlers (SIGINT, SIGTERM, SIGQUIT, SIGHUP) via tokio::signal inside a Tokio runtime. The `signal()` call returns a Result; if registering the SIGHUP handler fails at the OS level, the code panics with this expect message. This typically means the OS refused the signal-handler registration (signal.h sigaction failure).","triggerScenarios":"Calling the signal-registration function outside a Tokio runtime context, OS resource exhaustion (too many signal handlers/fds), or a platform where SIGHUP registration via tokio's SignalKind::hangup is unsupported.","commonSituations":"Embedding Vector's signal setup in a non-tokio async executor or running in restricted containers/seccomp sandboxes that block sigaction; hitting process file-descriptor limits.","solutions":["Ensure the signal setup runs inside a tokio runtime (runtime.block_on as in src/signal.rs)","Check ulimit -n and raise the file-descriptor limit","Verify the platform supports tokio signal handling (unix targets)","Run with elevated/unrestricted container settings if seccomp blocks signal syscalls"],"exampleFix":"// before\nlet mut sighup = signal(SignalKind::hangup()).expect(\"Failed to set up SIGHUP handler.\");\n// after\nlet mut sighup = signal(SignalKind::hangup()).map_err(|e| anyhow!(\"Failed to set up SIGHUP handler: {e}\"))?;","handlingStrategy":"fallback","validationCode":"// rust: ensure a tokio runtime exists before registering signals\nassert!(tokio::runtime::Handle::try_current().is_ok(), \"signal setup requires a tokio runtime\");\n// shell: check fd headroom\nulimit -n","typeGuard":"fn runtime_available() -> bool { tokio::runtime::Handle::try_current().is_ok() }","tryCatchPattern":"let mut sighup = signal(SignalKind::hangup()).map_err(|e| anyhow!(\"SIGHUP handler setup failed: {e}\"))?;","preventionTips":["Always register signals inside a tokio runtime","Raise the process fd limit before startup","Test startup in containers with seccomp profiles","Log and degrade gracefully if one signal handler fails"],"tags":["rust","signals","tokio","unix"],"backgroundTag":"internal-invariant-violation","analyzedSha":"bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013","analyzedAt":"2026-09-16T02:53:35.741Z","contentChangedAt":"2026-09-16T02:53:35.741Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}