mirror of
https://github.com/wahyd4/forego.git
synced 2026-08-09 05:07:05 +10:00
36 lines
692 B
Go
36 lines
692 B
Go
// +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)
|
|
}
|