Use setsid() instead of setpgid()

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.
This commit is contained in:
Magnus Bergmark 2019-01-17 13:21:27 +01:00
parent e0f649d79a
commit 9fd25dd667
No known key found for this signature in database
GPG Key ID: DB2D6BB84D8E0309
1 changed files with 1 additions and 1 deletions

View File

@ -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 {