File tree 3 files changed +26
-8
lines changed
3 files changed +26
-8
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ func runCommand(args []string) *exec.Cmd {
12
12
cmd := exec .Command (args [0 ], args [1 :]... )
13
13
cmd .Stdout = os .Stdout
14
14
cmd .Stderr = os .Stderr
15
- cmd . SysProcAttr = & syscall. SysProcAttr { Setpgid : true }
15
+ setProcAttr ( cmd )
16
16
17
17
fmt .Println ("[*] running command:" , cmd )
18
18
err := cmd .Start ()
@@ -28,14 +28,8 @@ func stopCommand(cmd *exec.Cmd) {
28
28
return
29
29
}
30
30
31
- err := syscall .Kill (- cmd .Process .Pid , syscall .Signal (0 ))
32
- if err != nil && err .Error () == "operation not permitted" {
33
- // process no longer running, nothing to do here
34
- return
35
- }
36
-
37
31
fmt .Println ("[*] stopping process" , cmd .Process .Pid )
38
- e := syscall . Kill ( - cmd .Process .Pid , syscall .SIGTERM )
32
+ e := cmd .Process .Signal ( syscall .SIGTERM )
39
33
if e != nil {
40
34
fmt .Println ("error killing child process:" , e )
41
35
}
Original file line number Diff line number Diff line change
1
+ //go:build linux || darwin
2
+
3
+ package vproxy
4
+
5
+ import (
6
+ "os/exec"
7
+ "syscall"
8
+ )
9
+
10
+ func setProcAttr (cmd * exec.Cmd ) {
11
+ cmd .SysProcAttr = & syscall.SysProcAttr {Setpgid : true }
12
+ }
Original file line number Diff line number Diff line change
1
+ //go:build windows
2
+
3
+ package vproxy
4
+
5
+ import (
6
+ "os/exec"
7
+ "syscall"
8
+ )
9
+
10
+ func setProcAttr (cmd * exec.Cmd ) {
11
+ cmd .SysProcAttr = & syscall.SysProcAttr {}
12
+ }
You can’t perform that action at this time.
0 commit comments