Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit 239acda

Browse files
committed
gps: Set pgroup controls in cmd constructor
1 parent 8de86c4 commit 239acda

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

internal/gps/cmd_unix.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@ func commandContext(ctx context.Context, name string, arg ...string) cmd {
3535
cancel: cancel,
3636
ctx: ctx,
3737
}
38+
39+
// Force subprocesses into their own process group, rather than being in the
40+
// same process group as the dep process. Because Ctrl-C sent from a
41+
// terminal will send the signal to the entire currently running process
42+
// group, this allows us to directly manage the issuance of signals to
43+
// subprocesses.
44+
c.Cmd.SysProcAttr = &syscall.SysProcAttr{
45+
Setpgid: true,
46+
Pgid: 0,
47+
}
48+
3849
return c
3950
}
4051

@@ -53,16 +64,6 @@ func (c cmd) CombinedOutput() ([]byte, error) {
5364
c.Cmd.Stdout = &b
5465
c.Cmd.Stderr = &b
5566

56-
// Force subprocesses into their own process group, rather than being in the
57-
// same process group as the dep process. Ctrl-C sent from a terminal will
58-
// send the signal to the entire running process group, so This allows us to
59-
// directly manage the issuance of signals to subprocesses in that common
60-
// case.
61-
c.Cmd.SysProcAttr = &syscall.SysProcAttr{
62-
Setpgid: true,
63-
Pgid: 0,
64-
}
65-
6667
if err := c.Cmd.Start(); err != nil {
6768
return nil, err
6869
}

0 commit comments

Comments
 (0)