jlcodes99/cockpit-tools · error

无法关闭实例进程,请手动关闭后重试

Error message

无法关闭实例进程,请手动关闭后重试

What it means

Returned by close_pids when, after sending close signals to all target PIDs and waiting up to timeout_secs, some processes are still running. The function gives up and returns "无法关闭实例进程,请手动关闭后重试" (cannot close instance processes, close them manually and retry), with the surviving PIDs written to the error log.

Source

Thrown at crates/cockpit-core/src/modules/process_core_lifecycle.rs:350

    if wait_pids_exit(&targets, timeout_secs) {
        crate::modules::logger::log_info(&format!(
            "[ClosePids] all exited, targets={}",
            summarize_pid_list_for_log(&targets)
        ));
        Ok(())
    } else {
        let remaining: Vec<u32> = targets
            .iter()
            .copied()
            .filter(|pid| is_pid_running(*pid))
            .collect();
        crate::modules::logger::log_error(&format!(
            "[ClosePids] timeout, remaining={}",
            summarize_pid_list_for_log(&remaining)
        ));
        Err("无法关闭实例进程,请手动关闭后重试".to_string())
    }
}

/// 启动 Antigravity IDE
pub fn start_antigravity() -> Result<u32, String> {
    start_antigravity_with_args("", &[])
}

/// 启动 Antigravity IDE(支持 user-data-dir 与附加参数)
pub fn start_antigravity_with_args(
    user_data_dir: &str,
    extra_args: &[String],
) -> Result<u32, String> {
    crate::modules::logger::log_info("正在启动 Antigravity IDE...");

    #[cfg(target_os = "macos")]
    let launch_path = resolve_antigravity_launch_path().ok();
    #[cfg(not(target_os = "macos"))]
    let launch_path = resolve_antigravity_launch_path()?;

View on GitHub (pinned to 1ed8b77992)

Solutions

  1. Manually close the remaining instance (quit the app or kill the PIDs listed in the '[ClosePids] timeout, remaining=' log line), then retry the operation.
  2. Force-kill the specific PIDs (e.g. `kill -9 <pid>` / Task Manager 'End task') if graceful close is ignored.
  3. Relaunch the app with elevated privileges if the target processes run as another user.
  4. Increase the close timeout if shutdowns are consistently slow on this machine.
  5. Reboot as a last resort to clear stuck/uninterruptible processes.

Example fix

// before: infinite retry loop on failure
loop { if close_trae().is_ok() { break; } }
// after: surface the message and stop retrying until the user intervenes
match close_trae() {
    Err(msg) if msg.contains("无法关闭实例进程") => {
        ui.prompt("请手动关闭实例进程后重试", show_remaining_pids_from_log());
    }
    r => handle(r),
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Check whether target processes can be signalled before attempting close
fn can_signal(pid: u32) -> bool {
    // on unix: signal 0 probe
    unsafe { libc::kill(pid as i32, 0) == 0 }
}

Type guard

fn is_manual_close_required(err: &str) -> bool {
    err == "无法关闭实例进程,请手动关闭后重试"
}

Try / catch

match close_managed_instances_common() {
    Err(msg) if is_manual_close_required(&msg) => {
        let pids = remaining_pids_from_close_log();
        ui.prompt(&format!("请手动关闭进程 {:?} 后重试", pids));
    }
    other => handle(other),
}

Prevention

When it happens

Trigger: Calling close_pids (via close_codex_instances, close_trae, close_opencode, close_managed_instances_common) when target processes ignore or block the close signal — hung GUI apps, elevated processes the current user can't signal, processes in uninterruptible I/O wait, or zombies — and don't exit within the timeout.

Common situations: IDE/app is frozen by an unresponsive plugin or dialog; process running as another user/admin requiring elevation; antivirus locking the process; very short timeout vs slow shutdown; Windows processes waiting on unsaved-state prompts.

Related errors


AI-assisted analysis of jlcodes99/cockpit-tools@1ed8b77992 (2026-09-05). Data as JSON: /api/errors/66136c3a9448b526. Report an issue: GitHub.