{"record":{"id":"1be83887958b2f43","repo":"vectordotdev/vector","slug":"failed-to-set-up-sigint-handler","errorCode":null,"errorMessage":"Failed to set up SIGINT handler.","messagePattern":"Failed to set up SIGINT handler\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/signal.rs","lineNumber":196,"sourceCode":"    }\n\n    /// 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\");","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/vectordotdev/vector/blob/3708c39b12a93212ed8b8d7510b4cc7769cb5864/src/signal.rs#L178-L214","documentation":"tokio's signal(SignalKind::interrupt()) registers a Unix signal handler and returns io::Result; Vector registers SIGINT inside os_signals() and unwraps with expect. If registration fails (signal syscalls blocked by the sandbox, handler/resource limits hit, or too many registrations in one process), Vector panics during startup. The four sibling expects cover SIGINT, SIGTERM, SIGQUIT and SIGHUP.","triggerScenarios":"Starting Vector in an environment where signal(2)/signalfd registration fails for SIGINT: a container seccomp/apparmor profile blocking signal syscalls, exhaustion of the fd/handler budget by many embedded runtimes (test harnesses), or a platform without the signal kind.","commonSituations":"Overly restrictive Docker/Kubernetes seccomp profiles; custom supervisors chaining signal handling; test harnesses that repeatedly create Tokio runtimes registering handlers; very low RLIMIT_NOFILE.","solutions":["Run with the default container seccomp profile or allow signal-related syscalls (rt_sigaction, signalfd) in the custom profile","Raise the file-descriptor limit (ulimit -n 65536, or LimitNOFILE= in systemd) if fd exhaustion is the cause","If supervising Vector, prefer its API or a clean exec-based handoff instead of installing conflicting handlers in the same process","Reproduce on the host outside the sandbox to confirm the environment, not the config, is at fault"],"exampleFix":"# before: custom seccomp blocks signal syscalls, Vector panics at boot\ndocker run --security-opt seccomp=strict.json vector:latest\n\n# after: default profile (or unconfined for diagnosis)\ndocker run vector:latest\n# and raise fd limits where needed:\n#   ulimit -n 65536","handlingStrategy":"validation","validationCode":"# fail fast before launching Vector\n[ \"$(ulimit -n)\" -ge 4096 ] || ulimit -n 4096\nvector validate /etc/vector/vector.toml && exec vector --config /etc/vector/vector.toml","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run containers with the default seccomp profile; allowlist rt_sigaction and signalfd syscalls if customizing","Keep RLIMIT_NOFILE high (LimitNOFILE=65536) on systemd/docker units","Register signal handlers once per process when embedding Vector; share the stream across tasks"],"tags":["rust","vector","tokio","signals","unix","startup","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"}