{"record":{"id":"9a5edf43dbeb8a0e","repo":"zellij-org/zellij","slug":"failed-to-set-controlling-terminal","errorCode":null,"errorMessage":"failed to set controlling terminal","messagePattern":"failed to set controlling terminal","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"zellij-server/src/os_input_output_unix.rs","lineNumber":229,"sourceCode":"    let mut child = unsafe {\n        let cmd = cmd.clone();\n        let command = &mut Command::new(cmd.command);\n        if let Some(current_dir) = cmd.cwd {\n            if current_dir.exists() && current_dir.is_dir() {\n                command.current_dir(current_dir);\n            } else {\n                log::error!(\n                    \"Failed to set CWD for new pane. '{}' does not exist or is not a folder\",\n                    current_dir.display()\n                );\n            }\n        }\n        command\n            .args(&cmd.args)\n            .env(\"ZELLIJ_PANE_ID\", &format!(\"{}\", terminal_id))\n            .pre_exec(move || -> io::Result<()> {\n                if libc::login_tty(pid_secondary) != 0 {\n                    panic!(\"failed to set controlling terminal\");\n                }\n                close_fds::close_open_fds(3, &[]);\n                Ok(())\n            })\n            .spawn()\n            .expect(\"failed to spawn\")\n    };\n\n    let child_id = child.id();\n    thread::spawn(move || {\n        child.wait().with_context(|| err_context(&cmd)).fatal();\n        let exit_status = handle_command_exit(child)\n            .with_context(|| err_context(&cmd))\n            .fatal();\n        let _ = unistd::close(pid_secondary);\n        quit_cb(PaneId::Terminal(terminal_id), exit_status, cmd);\n    });\n","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/zellij-org/zellij/blob/5cb5df5cce4e16c5d1c57c7c062e4a90a7823c41/zellij-server/src/os_input_output_unix.rs#L211-L247","documentation":"Error \"failed to set controlling terminal\" thrown in zellij-org/zellij.","triggerScenarios":"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.","commonSituations":"Seen when the environment lacks a controlling tty or the session setup order is wrong.","solutions":["Ensure the process is a session leader before spawning (setsid) and that a tty is available.","Run zellij from an interactive terminal rather than a detached environment."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5cb5df5cce4e16c5d1c57c7c062e4a90a7823c41","analyzedAt":"2026-08-19T07:42:58.758Z","contentChangedAt":"2026-08-19T07:42:58.758Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}