{"record":{"id":"9f76a41b31017372","repo":"vectordotdev/vector","slug":"failed-to-set-up-sigterm-handler","errorCode":null,"errorMessage":"Failed to set up SIGTERM handler.","messagePattern":"Failed to set up SIGTERM handler\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/signal.rs","lineNumber":198,"sourceCode":"    /// Shutdown active signal handlers.\n    pub fn clear(&mut self) {\n        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                    },","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/vectordotdev/vector/blob/3708c39b12a93212ed8b8d7510b4cc7769cb5864/src/signal.rs#L180-L216","documentation":"Vector registers a SIGTERM handler via tokio::signal::unix::signal(SignalKind::terminate()) and unwraps the io::Result with expect. Registration can fail if the environment forbids or exhausts signal-handler setup (sandboxed containers, fd/handler limits, many embedded runtimes), and then the process panics at startup instead of accepting SIGTERM for graceful shutdown.","triggerScenarios":"Starting Vector where SIGTERM registration fails: seccomp/apparmor denying sigaction or signalfd, RLIMIT_NOFILE exhausted, or a test/binary embedding Vector that already registered the maximum number of handlers.","commonSituations":"Kubernetes nodes with custom seccomp profiles; minimal distroless/scratch images run under strict LSM policies; repeated runtime creation in integration tests.","solutions":["Use the default container seccomp profile or add rt_sigaction/signalfd to the allowlist","Raise RLIMIT_NOFILE (ulimit -n 65536; LimitNOFILE= in the unit)","In embedding scenarios, register signal handling once and share the stream instead of per-runtime registration","Verify outside the sandbox to confirm the environment is the cause"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# preflight: signal syscalls available and fds available\nulimit -n\nvector validate /etc/vector/vector.toml && vector --config /etc/vector/vector.toml","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer default container security profiles over hand-rolled seccomp allowlists","Test graceful shutdown (kill -TERM) in staging with the same security context as production","When embedding Vector, let it own signal handling; do not stack competing SIGTERM registrations"],"tags":["rust","vector","tokio","signals","unix","sigterm","panic"],"backgroundTag":"signal-handler-registration-failed","analyzedSha":"3708c39b12a93212ed8b8d7510b4cc7769cb5864","analyzedAt":"2026-08-20T07:02:18.786Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T20:17:18.057Z"}