zellij-org/zellij · error

failed to set controlling terminal

Error message

failed to set controlling terminal

What it means

Error "failed to set controlling terminal" thrown in zellij-org/zellij.

Source

Thrown at zellij-server/src/os_input_output_unix.rs:229

    let mut child = unsafe {
        let cmd = cmd.clone();
        let command = &mut Command::new(cmd.command);
        if let Some(current_dir) = cmd.cwd {
            if current_dir.exists() && current_dir.is_dir() {
                command.current_dir(current_dir);
            } else {
                log::error!(
                    "Failed to set CWD for new pane. '{}' does not exist or is not a folder",
                    current_dir.display()
                );
            }
        }
        command
            .args(&cmd.args)
            .env("ZELLIJ_PANE_ID", &format!("{}", terminal_id))
            .pre_exec(move || -> io::Result<()> {
                if libc::login_tty(pid_secondary) != 0 {
                    panic!("failed to set controlling terminal");
                }
                close_fds::close_open_fds(3, &[]);
                Ok(())
            })
            .spawn()
            .expect("failed to spawn")
    };

    let child_id = child.id();
    thread::spawn(move || {
        child.wait().with_context(|| err_context(&cmd)).fatal();
        let exit_status = handle_command_exit(child)
            .with_context(|| err_context(&cmd))
            .fatal();
        let _ = unistd::close(pid_secondary);
        quit_cb(PaneId::Terminal(terminal_id), exit_status, cmd);
    });

View on GitHub (pinned to 5cb5df5cce)

Solutions

  1. Ensure the process is a session leader before spawning (setsid) and that a tty is available.
  2. Run zellij from an interactive terminal rather than a detached environment.

When it happens

Trigger: Occurs at zellij-server/src/os_input_output_unix.rs:229 when the operation fails: "failed to set controlling terminal". Currently there is no defensive handling preventing or contextualizing this failure before it surfaces.

Common situations: Seen when the environment lacks a controlling tty or the session setup order is wrong.


AI-assisted analysis of zellij-org/zellij@5cb5df5cce (2026-08-19). Data as JSON: /api/errors/9a5edf43dbeb8a0e. Report an issue: GitHub.