summaryrefslogtreecommitdiffstats
path: root/zellij-server/src/os_input_output.rs
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2024-04-12 15:39:36 +0200
committerGitHub <noreply@github.com>2024-04-12 15:39:36 +0200
commite68bc649d63d51178d224be3af7109ca324480f4 (patch)
treea3993ee2833b7b5ac952a35617c7037132571b71 /zellij-server/src/os_input_output.rs
parenta0f48c6731473b17a485c9967e80359826a5373c (diff)
feat(cli): allow starting a session detached (#3257)
* feat(cli): allow starting a session detached * fix tests
Diffstat (limited to 'zellij-server/src/os_input_output.rs')
-rw-r--r--zellij-server/src/os_input_output.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/zellij-server/src/os_input_output.rs b/zellij-server/src/os_input_output.rs
index a2d9e36a8..640b6fbc9 100644
--- a/zellij-server/src/os_input_output.rs
+++ b/zellij-server/src/os_input_output.rs
@@ -221,7 +221,7 @@ fn handle_openpty(
fn handle_terminal(
cmd: RunCommand,
failover_cmd: Option<RunCommand>,
- orig_termios: termios::Termios,
+ orig_termios: Option<termios::Termios>,
quit_cb: Box<dyn Fn(PaneId, Option<i32>, RunCommand) + Send>,
terminal_id: u32,
) -> Result<(RawFd, RawFd)> {
@@ -229,7 +229,7 @@ fn handle_terminal(
// Create a pipe to allow the child the communicate the shell's pid to its
// parent.
- match openpty(None, Some(&orig_termios)) {
+ match openpty(None, &orig_termios) {
Ok(open_pty_res) => handle_openpty(open_pty_res, cmd, quit_cb, terminal_id),
Err(e) => match failover_cmd {
Some(failover_cmd) => {
@@ -279,7 +279,7 @@ fn separate_command_arguments(command: &mut PathBuf, args: &mut Vec<String>) {
/// set.
fn spawn_terminal(
terminal_action: TerminalAction,
- orig_termios: termios::Termios,
+ orig_termios: Option<termios::Termios>,
quit_cb: Box<dyn Fn(PaneId, Option<i32>, RunCommand) + Send>, // u32 is the exit_status
default_editor: Option<PathBuf>,
terminal_id: u32,
@@ -418,7 +418,7 @@ impl ClientSender {
#[derive(Clone)]
pub struct ServerOsInputOutput {
- orig_termios: Arc<Mutex<termios::Termios>>,
+ orig_termios: Arc<Mutex<Option<termios::Termios>>>,
client_senders: Arc<Mutex<HashMap<ClientId, ClientSender>>>,
terminal_id_to_raw_fd: Arc<Mutex<BTreeMap<u32, Option<RawFd>>>>, // A value of None means the
// terminal_id exists but is
@@ -876,7 +876,10 @@ impl Clone for Box<dyn ServerOsApi> {
}
pub fn get_server_os_input() -> Result<ServerOsInputOutput, nix::Error> {
- let current_termios = termios::tcgetattr(0)?;
+ let current_termios = termios::tcgetattr(0).ok();
+ if current_termios.is_none() {
+ log::warn!("Starting a server without a controlling terminal, using the default termios configuration.");
+ }
let orig_termios = Arc::new(Mutex::new(current_termios));
Ok(ServerOsInputOutput {
orig_termios,