Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Newdigate <andrew@troupe.co>2017-04-25 18:46:22 +0300
committerAndrew Newdigate <andrew@troupe.co>2017-04-25 18:46:22 +0300
commit19aabc1a95f27a76e5d6e80dc989f548471b516d (patch)
treef5116bb53f724452645ce703d254a9f8e385f330
parent1e7a5c6dd3d54974b000933da9dc966e2e213cea (diff)
First stab in the dark at context cleanup
-rw-r--r--internal/helper/command_wrapper_go1.6.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/internal/helper/command_wrapper_go1.6.go b/internal/helper/command_wrapper_go1.6.go
index 71cef0ac8..e7d83e4d1 100644
--- a/internal/helper/command_wrapper_go1.6.go
+++ b/internal/helper/command_wrapper_go1.6.go
@@ -3,6 +3,7 @@
package helper
import (
+ "log"
"os/exec"
"golang.org/x/net/context"
@@ -10,5 +11,15 @@ import (
// CommandWrapper handles context until we compile using Go 1.7
func CommandWrapper(ctx context.Context, name string, arg ...string) *exec.Cmd {
- return exec.Command(name, arg...)
+ command := exec.Command(name, arg...)
+
+ if ctx != nil {
+ go func() {
+ <-ctx.Done()
+ log.Printf("Context done, killing process")
+ command.Kill()
+ }()
+ }
+
+ return command
}