mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-30 18:00:56 +01:00
fixed build error of windows
This commit is contained in:
30
backend/services/sys_exec/linux_mac.go
Normal file
30
backend/services/sys_exec/linux_mac.go
Normal file
@@ -0,0 +1,30 @@
|
||||
// +build !windows
|
||||
|
||||
package sys_exec
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func BuildCmd(cmdStr string) *exec.Cmd {
|
||||
return exec.Command("sh", "-c", cmdStr)
|
||||
}
|
||||
|
||||
func Setpgid(cmd *exec.Cmd) {
|
||||
if cmd == nil {
|
||||
return
|
||||
}
|
||||
if cmd.SysProcAttr == nil {
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
||||
} else {
|
||||
cmd.SysProcAttr.Setpgid = true
|
||||
}
|
||||
}
|
||||
|
||||
func KillProcess(cmd *exec.Cmd) error {
|
||||
if cmd == nil {
|
||||
return nil
|
||||
}
|
||||
return syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)
|
||||
}
|
||||
Reference in New Issue
Block a user