From ccd0acb1a3b1df5362b43c6918037ade4b2c840a Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 18 Jan 2022 01:40:55 -0500 Subject: don't mess with the foreground pg if we're just using -c --- src/runner/mod.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/runner/mod.rs b/src/runner/mod.rs index 1633ba0..01a87b9 100644 --- a/src/runner/mod.rs +++ b/src/runner/mod.rs @@ -251,9 +251,12 @@ async fn run_pipeline( let pwd = env.pwd().to_path_buf(); let pipeline = pipeline.eval(env).await?; - let (children, pg) = spawn_children(pipeline, env, &io)?; + let interactive = shell_write.is_some(); + let (children, pg) = spawn_children(pipeline, env, &io, interactive)?; let status = wait_children(children, pg, env, &io, shell_write).await; - set_foreground_pg(nix::unistd::getpid())?; + if interactive { + set_foreground_pg(nix::unistd::getpid())?; + } env.update()?; env.set_status(status); if env.pwd() != pwd { @@ -277,6 +280,7 @@ fn spawn_children<'a>( pipeline: crate::parse::Pipeline, env: &'a Env, io: &builtins::Io, + interactive: bool, ) -> anyhow::Result<(Vec>, Option)> { let mut cmds: Vec<_> = pipeline .into_exes() @@ -304,7 +308,9 @@ fn spawn_children<'a>( setpgid_parent(child_pid, pg_pid)?; if pg_pid.is_none() { pg_pid = Some(child_pid); - set_foreground_pg(child_pid)?; + if interactive { + set_foreground_pg(child_pid)?; + } } } children.push(child); -- cgit v1.2.3-54-g00ecf