From 296fa4ce873c158b8c87d21db3e566c8ae365504 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 17 Jan 2022 00:11:52 -0500 Subject: stop sending environment stuff over a pipe sending it through the actual environment should be sufficient --- src/shell/history/mod.rs | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) (limited to 'src/shell/history/mod.rs') diff --git a/src/shell/history/mod.rs b/src/shell/history/mod.rs index 2863cad..ad83e92 100644 --- a/src/shell/history/mod.rs +++ b/src/shell/history/mod.rs @@ -283,31 +283,19 @@ async fn spawn_commands( event_w: async_std::channel::Sender, ) -> anyhow::Result { let mut cmd = pty_process::Command::new(std::env::current_exe()?); - cmd.arg("--internal-cmd-runner"); + cmd.args(&["-c", cmdline]); env.apply(&mut cmd); - let (to_r, to_w) = nix::unistd::pipe2(nix::fcntl::OFlag::O_CLOEXEC)?; let (from_r, from_w) = nix::unistd::pipe2(nix::fcntl::OFlag::O_CLOEXEC)?; // Safety: dup2 is an async-signal-safe function unsafe { cmd.pre_exec(move || { - nix::unistd::dup2(to_r, 3)?; - nix::unistd::dup2(from_w, 4)?; + nix::unistd::dup2(from_w, 3)?; Ok(()) }); } let child = pty.spawn(cmd)?; - nix::unistd::close(to_r)?; nix::unistd::close(from_w)?; - // Safety: to_w was just opened above, was not used until now, and can't - // be used after this because from_raw_fd takes it by move - write_env( - unsafe { async_std::fs::File::from_raw_fd(to_w) }, - cmdline, - env, - ) - .await?; - let (read_w, read_r) = async_std::channel::unbounded(); let new_read = move || { let read_w = read_w.clone(); @@ -394,13 +382,3 @@ async fn spawn_commands( } } } - -async fn write_env( - mut to_w: async_std::fs::File, - pipeline: &str, - env: &Env, -) -> anyhow::Result<()> { - to_w.write_all(&bincode::serialize(pipeline)?).await?; - to_w.write_all(&env.as_bytes()).await?; - Ok(()) -} -- cgit v1.2.3-54-g00ecf