Files
forego/unix.go
T
2014-05-22 07:56:00 +01:00

39 lines
746 B
Go

// +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{"/bin/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)
}