diff options
author | Jesse Luehrs <doy@tozt.net> | 2022-01-18 01:40:55 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2022-01-18 01:40:55 -0500 |
commit | ccd0acb1a3b1df5362b43c6918037ade4b2c840a (patch) | |
tree | cdef7815824778c51f12db91cae2763665cc74a6 /src | |
parent | 4b76cb2100fdefecff79e2999b2a648eb149018b (diff) | |
download | nbsh-ccd0acb1a3b1df5362b43c6918037ade4b2c840a.tar.gz nbsh-ccd0acb1a3b1df5362b43c6918037ade4b2c840a.zip |
don't mess with the foreground pg if we're just using -c
Diffstat (limited to 'src')
-rw-r--r-- | src/runner/mod.rs | 12 |
1 files changed, 9 insertions, 3 deletions
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<Child<'a>>, Option<nix::unistd::Pid>)> { 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); |