Merge pull request #15 from jweslley/build_constraints

use build constraints
This commit is contained in:
David Dollar
2014-05-10 10:07:59 -04:00
3 changed files with 4 additions and 48 deletions
-48
View File
@@ -1,48 +0,0 @@
package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"syscall"
"time"
)
func (p *Process) Start() {
command := []string{"/bin/bash", p.shellArgument(), fmt.Sprintf("source \"%s\" 2>/dev/null; %s", filepath.Join(p.Root, ".profile"), p.Command)}
p.cmd = exec.Command(command[0], command[1:]...)
p.cmd.Dir = p.Root
p.cmd.Env = p.envAsArray()
p.cmd.Stdin = p.Stdin
p.cmd.Stdout = p.Stdout
p.cmd.Stderr = p.Stderr
if !p.Interactive {
p.cmd.SysProcAttr = &syscall.SysProcAttr{}
p.cmd.SysProcAttr.Setsid = true
}
p.cmd.Start()
}
func (p *Process) Signal(signal syscall.Signal) {
if p.Running() {
group, _ := os.FindProcess(-1 * p.Pid())
group.Signal(signal)
}
}
func ShutdownProcesses(of *OutletFactory) {
shutdown_mutex.Lock()
of.SystemOutput("shutting down")
for name, ps := range processes {
of.SystemOutput(fmt.Sprintf("sending SIGTERM to %s", name))
ps.Signal(syscall.SIGTERM)
}
go func() {
time.Sleep(shutdownGraceTime)
for name, ps := range processes {
of.SystemOutput(fmt.Sprintf("sending SIGKILL to %s", name))
ps.Signal(syscall.SIGKILL)
}
}()
}
+2
View File
@@ -1,5 +1,7 @@
package main
// +build darwin freebsd linux netbsd openbsd
import (
"fmt"
"os"
+2
View File
@@ -1,5 +1,7 @@
package main
// +build windows
import (
"fmt"
"os"