quickwit-oss/quickwit · error

registering a signal handler for SIGINT should not fail

Error message

registering a signal handler for SIGINT should not fail

What it means

The CLI installs a tokio signal handler for Ctrl-C so a graceful shutdown can start. tokio::signal::ctrl_c() returns a Result that fails only if the handler cannot be registered (e.g. signals unavailable); the code asserts with expect that this never happens, since without a SIGINT handler the binary cannot shut down gracefully at all.

Source

Thrown at quickwit/quickwit-cli/src/service.rs:56

        .arg(config_cli_arg())
        .args(&[
            arg!(--"service" <SERVICE> "Services (`indexer`, `searcher`, `metastore`, `metastore-read-replica`, `control-plane`, or `janitor`) to run. If unspecified, services from the config are used.")
                .action(ArgAction::Append)
                .required(false),
        ])
}

#[derive(Debug, Eq, PartialEq)]
pub struct RunCliCommand {
    pub config_uri: Uri,
    pub services: Option<HashSet<QuickwitService>>,
}

async fn listen_interrupt() {
    async fn ctrl_c() {
        signal::ctrl_c()
            .await
            .expect("registering a signal handler for SIGINT should not fail");
        // carriage return to hide the ^C echo from the terminal
        print!("\r");
    }
    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);
    });
}

View on GitHub (pinned to a39730c5cd)

Solutions

  1. Run quickwit in an environment where SIGINT handling is permitted (normal container/init systems allow it).
  2. If signals are blocked, guard the registration: log the error and continue instead of panicking via expect.
  3. Check seccomp/AppArmor policies and allow rt_sigaction/sigaltstack syscalls.

Example fix

// before
signal::ctrl_c().await.expect("registering a signal handler for SIGINT should not fail");
// after
if let Err(err) = signal::ctrl_c().await {
    error!(error = ?err, "failed to register SIGINT handler; graceful shutdown on Ctrl-C disabled");
    return;
}
Defensive patterns

Strategy: try-catch

Try / catch

match signal::ctrl_c().await {
    Ok(()) => initiate_graceful_shutdown(),
    Err(err) => error!(error = ?err, "SIGINT handler registration failed; continuing without it"),
}

Prevention

When it happens

Trigger: tokio::signal::ctrl_c() returning Err while listen_interrupt spawns the ctrl_c task — practically only when OS signal delivery is unavailable (exotic sandbox/seccomp environments blocking signal registration).

Common situations: Running quickwit inside heavily restricted containers or sandboxes that disable signal syscalls; running under init systems that mask signal masks; embedded/minimal libc environments.

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


AI-assisted analysis of quickwit-oss/quickwit@a39730c5cd (2026-09-08). Data as JSON: /api/errors/edbafb1dddba08f8. Report an issue: GitHub.