forked from ddollar/forego
-
Notifications
You must be signed in to change notification settings - Fork 21
/
unix.go
38 lines (30 loc) · 741 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
36
37
38
// +build darwin freebsd linux netbsd openbsd
package main
import (
"fmt"
"path/filepath"
"syscall"
)
const osHaveSigTerm = true
func ShellInvocationCommand(interactive bool, root, command string) []string {
shellArgument := "-c"
if interactive {
shellArgument = "-ic"
}
profile := filepath.Join(root, ".profile")
shellCommand := fmt.Sprintf("source \"%s\" 2>/dev/null; %s", profile, command)
return []string{"bash", 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)
}