From 9fd25dd667f41b0b7b9686358652cf054a973f5c Mon Sep 17 00:00:00 2001 From: Magnus Bergmark Date: Thu, 17 Jan 2019 13:21:27 +0100 Subject: [PATCH] Use setsid() instead of setpgid() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes it possible to run commands that allocates TTYs and still capture their output and reap the process on completion. > setpgid — set process group ID for job control > setsid — create session and set process group ID With this in place, the `waitpid` call detects that the process has exited even if the process allocated a TTY, and is able to unblock the runner and continue. Further, the output of the command is also shown in the controlling terminal. --- src/process.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/process.rs b/src/process.rs index 77c0c19..ee4c054 100644 --- a/src/process.rs +++ b/src/process.rs @@ -114,7 +114,7 @@ mod imp { } command - .before_exec(|| setpgid(Pid::from_raw(0), Pid::from_raw(0)).map_err(from_nix_error)) + .before_exec(|| setsid().map_err(from_nix_error).map(|_|())) .spawn() .and_then(|p| { Ok(Process {