-
Notifications
You must be signed in to change notification settings - Fork 176
/
unix.go
35 lines (28 loc) · 692 Bytes
/
unix.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// +build darwin freebsd linux netbsd openbsd
package main
import (
"fmt"
"syscall"
)
const osHaveSigTerm = true
func ShellInvocationCommand(interactive bool, root, command string) []string {
shellArgument := "-c"
if interactive {
shellArgument = "-ic"
}
shellCommand := fmt.Sprintf("cd \"%s\"; source .profile 2>/dev/null; exec %s", root, command)
return []string{"sh", shellArgument, shellCommand}
}
func (p *Process) PlatformSpecificInit() {
if !p.Interactive {
p.SysProcAttr = &syscall.SysProcAttr{}
p.SysProcAttr.Setsid = true
}
return
}
func (p *Process) SendSigTerm() {
p.Signal(syscall.SIGTERM)
}
func (p *Process) SendSigKill() {
p.Signal(syscall.SIGKILL)
}