1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/vendor/github.com/moby/buildkit/source/git/gitsource_unix.go
Tonis Tiigi 6fcb36ff14 vendor: add buildkit dependency
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-06-10 10:05:19 -07:00

27 lines
458 B
Go

// +build !windows
package git
import (
"context"
"os/exec"
"syscall"
)
func runProcessGroup(ctx context.Context, cmd *exec.Cmd) error {
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
if err := cmd.Start(); err != nil {
return err
}
waitDone := make(chan struct{})
go func() {
select {
case <-ctx.Done():
syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)
case <-waitDone:
}
}()
err := cmd.Wait()
close(waitDone)
return err
}