sigoden/dufs · critical

Failed to install CTRL+C signal handler

Error message

Failed to install CTRL+C signal handler

What it means

`shutdown_signal` awaits tokio's CTRL+C handler; if the runtime fails to register the SIGINT handler, the code panics via `.expect` with this message. This is a fatal startup/runtime condition, not a request error — tokio::signal can fail when signal handling is unavailable in the environment.

Solutions

  1. Run on a supported platform (Linux/macOS/Windows) with standard signal support.
  2. Check container/sandbox security profiles that block sigaction/signal syscalls.
  3. Upgrade tokio to a version supporting the target platform.
  4. Wrap shutdown in an alternative (e.g. poll a flag file) if signals are inherently unavailable.

Example fix

// before
async fn shutdown_signal() {
    tokio::signal::ctrl_c().await.expect("Failed to install CTRL+C signal handler")
}
// after
async fn shutdown_signal() {
    if tokio::signal::ctrl_c().await.is_err() {
        eprintln!("ctrl_c unavailable; falling back");
        std::future::pending::<()>().await;
    }
}
Defensive patterns

Strategy: fallback

Validate before calling

#[cfg(unix)]
fn signals_supported() -> bool { true } // else check target support before relying on ctrl_c

Try / catch

tokio::select! { _ = tokio::signal::ctrl_c() => {}, _ = manual_shutdown_watch() => {} }

Prevention

When it happens

Trigger: Running on a platform/environment where SIGINT handling cannot be installed (unsupported platform, restricted sandbox, signal dispositions blocked by the container runtime).

Common situations: Minimal containers without signal support; running under restrictive seccomp profiles; exotic/embedded targets unsupported by tokio's signal driver.

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 sigoden/dufs@fe7fd564f8 (2026-09-09). Data as JSON: /api/errors/d9ef3fb78d29ef39. Report an issue: GitHub.

Appendix: source

Thrown at src/main.rs:308

    if urls.len() == 1 {
        output.push_str(&format!("Listening on {}", urls[0]))
    } else {
        let info = urls
            .iter()
            .map(|v| format!("  {v}"))
            .collect::<Vec<String>>()
            .join("\n");
        output.push_str(&format!("Listening on:\n{info}\n"))
    }

    Ok(output)
}

async fn shutdown_signal() {
    tokio::signal::ctrl_c()
        .await
        .expect("Failed to install CTRL+C signal handler")
}

View on GitHub (pinned to fe7fd564f8)