atuinsh/atuin · error

failed to listen for ctrl+c

Error message

failed to listen for ctrl+c

What it means

On non-Unix builds (Windows), atuin-daemon's shutdown_signal() awaits tokio::signal::ctrl_c(). This fails when the runtime has no IO driver enabled or the OS console-control registration (SetConsoleCtrlHandler) fails. The expect panics with 'failed to listen for ctrl+c' at daemon startup.

Source

Thrown at crates/atuin-daemon/src/lib.rs:135

#[cfg(unix)]
async fn shutdown_signal() {
    let mut term = tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate())
        .expect("failed to register sigterm handler");
    let mut int = tokio::signal::unix::signal(tokio::signal::unix::SignalKind::interrupt())
        .expect("failed to register sigint handler");

    tokio::select! {
        _ = term.recv() => {},
        _ = int.recv() => {},
    }
}

/// Wait for a shutdown signal (Ctrl+C).
#[cfg(not(unix))]
async fn shutdown_signal() {
    tokio::signal::ctrl_c()
        .await
        .expect("failed to listen for ctrl+c");
}

View on GitHub (pinned to 202f6ad98e)

Solutions

  1. Run the daemon through the shipped atuin binary, which constructs a fully enabled runtime
  2. When embedding on Windows, build the runtime with .enable_all() before awaiting ctrl_c()
  3. Verify the service account may register console control handlers

Example fix

// before
let rt = tokio::runtime::Builder::new_multi_thread().build()?;

// after — ctrl_c() needs the IO driver
let rt = tokio::runtime::Builder::new_multi_thread()
    .enable_all()
    .build()?;
Defensive patterns

Strategy: validation

Validate before calling

let rt = tokio::runtime::Builder::new_multi_thread()
    .enable_all() // ctrl_c() needs the IO driver
    .build()?;
rt.block_on(async { /* daemon code incl. shutdown_signal() */ });

Try / catch

if let Err(e) = tokio::signal::ctrl_c().await {
    tracing::error!("ctrl+c listener unavailable: {e}; shutting down on completion instead");
}

Prevention

When it happens

Trigger: Running the daemon on Windows inside a runtime built without enable_all()/enable_io(); the service account being unable to install a console control handler; restricted console environments.

Common situations: Windows service wrappers hosting atuin-daemon with a hand-built runtime; CI on Windows runners with constrained console access.

Related errors


AI-assisted analysis of atuinsh/atuin@202f6ad98e (2026-08-16). Data as JSON: /api/errors/b6fdb4f50dda7128. Report an issue: GitHub.