quickwit-oss/quickwit · error
registering a signal handler for SIGTERM should not fail
Error message
registering a signal handler for SIGTERM should not fail
What it means
In listen_sigterm, the code registers a tokio unix signal handler for SIGTERM. Registration fails only if the signal number is out of range or signals cannot be registered; the expect asserts this cannot happen because a server that cannot catch SIGTERM cannot drain in-flight indexing before being killed.
Source
Thrown at quickwit/quickwit-cli/src/service.rs:78
ctrl_c().await;
println!(
"{} Graceful shutdown initiated. Waiting for ingested data to be indexed. This may take a \
few minutes. Press Ctrl+C again to force shutdown.",
"❢".color(BLUE_COLOR)
);
tokio::spawn(async {
ctrl_c().await;
println!(
"{} Quickwit was forcefully shut down. Some data might not have been indexed.",
"✘".color(RED_COLOR)
);
std::process::exit(1);
});
}
async fn listen_sigterm() {
signal::unix::signal(signal::unix::SignalKind::terminate())
.expect("registering a signal handler for SIGTERM should not fail")
.recv()
.await;
info!("SIGTERM received");
}
async fn listen_sighup() {
let mut sighup = signal::unix::signal(signal::unix::SignalKind::hangup())
.expect("registering a signal handler for SIGHUP should not fail");
while sighup.recv().await.is_some() {
info!("SIGHUP received");
reload_tls_cert();
}
}
impl RunCliCommand {
pub fn parse_cli_args(mut matches: ArgMatches) -> anyhow::Result<Self> {
let config_uri = matchesView on GitHub (pinned to a39730c5cd)
Solutions
- Deploy quickwit under a normal init/container runtime that permits signal registration.
- Allow the rt_sigaction syscall in seccomp/AppArmor profiles.
- Replace the expect with graceful error handling that logs and falls back to default termination behavior.
Example fix
// before
signal::unix::signal(signal::unix::SignalKind::terminate())
.expect("registering a signal handler for SIGTERM should not fail")
// after
let mut sigterm = signal::unix::signal(signal::unix::SignalKind::terminate())
.context("failed to register SIGTERM handler")?; Defensive patterns
Strategy: try-catch
Try / catch
let mut sigterm = signal::unix::signal(signal::unix::SignalKind::terminate())
.map_err(|err| anyhow::anyhow!("SIGTERM handler registration failed: {err}"))?; Prevention
- Deploy under init systems that do not block SIGTERM.
- Allow signal syscalls in container security profiles.
- Test graceful shutdown (`kubectl delete pod`) in CI to catch registration regressions early.
When it happens
Trigger: signal::unix::signal(SignalKind::terminate()) returning Err while executing the quickwit serve command on Unix — only when signal handler registration is blocked by the OS.
Common situations: Hardened containers with seccomp filters stripping rt_sigaction; unusual init setups with signal masks that leak SIGTERM to blocked; running on platforms where unix signal APIs are unavailable (would not compile).
Understand the failure class
Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.
Related errors
- registering a signal handler for SIGINT should not fail
- registering a signal handler for SIGHUP should not fail
- Failed to create `OffsetDateTime` from split create timestam
- Failed to create `OffsetDateTime` from split update timestam
- node not found in pending
AI-assisted analysis of quickwit-oss/quickwit@a39730c5cd (2026-09-08).
Data as JSON: /api/errors/ffa9d39197a04215.
Report an issue: GitHub.