atuinsh/atuin · error

Process with current pid does not exist

Error message

Process with current pid does not exist

What it means

After resolving the current PID, Shell::current looks it up in the sysinfo process table. If the OS reports a PID for this process but the table has no such entry, the expect panics with 'Process with current pid does not exist'. This is an internal consistency failure between the OS PID allocation and the snapshot taken by System::new_all().

Source

Thrown at crates/atuin-common/src/shell.rs:45

}

#[derive(Debug, Error, Serialize)]
pub enum ShellError {
    #[error("shell not supported")]
    NotSupported,

    #[error("failed to execute shell command: {0}")]
    ExecError(String),
}

impl Shell {
    #[must_use]
    pub fn current() -> Self {
        let sys = System::new_all();

        let process = sys
            .process(get_current_pid().expect("Failed to get current PID"))
            .expect("Process with current pid does not exist");

        let parent = sys
            .process(process.parent().expect("Atuin running with no parent!"))
            .expect("Process with parent pid does not exist");

        let shell = parent.name().to_string_lossy().trim().to_lowercase();
        let shell = shell.strip_prefix('-').unwrap_or(&shell);

        Self::from_string(shell)
    }

    #[must_use]
    pub fn from_env() -> Self {
        std::env::var("ATUIN_SHELL")
            .map_or(Self::Unknown, |shell| Self::from_string(&shell.trim().to_lowercase()))
    }

    #[must_use]

View on GitHub (pinned to c0c717ab04)

Solutions

  1. Retry the call — the race with process exit is transient.
  2. Check that /proc is mounted and readable in the container/sandbox.
  3. Update the sysinfo crate to a version fixing platform-specific process enumeration bugs.
  4. Replace the expect with a fallback shell guess (e.g. $SHELL env var) in embedded usage.

Example fix

// before
let process = sys.process(get_current_pid().expect("Failed to get current PID"))
    .expect("Process with current pid does not exist");

// after
let process = get_current_pid().ok().and_then(|pid| sys.process(pid))
    .ok_or_else(|| std::env::var("SHELL").unwrap_or_default().into())?;
Defensive patterns

Strategy: fallback

Validate before calling

// Rust: pre-check the current pid is resolvable before relying on Shell::current
let pid_ok = sysinfo::get_current_pid().is_ok();
if !pid_ok {
    // use $SHELL fallback instead of Shell::current()
}

Try / catch

// Rust
let shell = std::panic::catch_unwind(Shell::current)
    .ok()
    .or_else(|| std::env::var("SHELL").ok().map(|s| Shell::from_string(&s)));

Prevention

When it happens

Trigger: Calling Shell::current when the sysinfo System::new_all() snapshot misses the current process — e.g. the process exits during snapshotting, or the platform backend enumerates an incomplete process list.

Common situations: Race with process exit in short-lived hook invocations; sandboxed/containerized environments with restricted /proc visibility; sysinfo bugs on specific kernels.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of atuinsh/atuin@c0c717ab04 (2026-09-12). Data as JSON: /api/errors/fc7da781cd7c4843. Report an issue: GitHub.