agent/proxy: fix build on Windows

This commit is contained in:
Mitchell Hashimoto 2018-06-07 10:27:28 -07:00 committed by Jack Pearkes
parent 67d8cae7d0
commit 7846206753
3 changed files with 16 additions and 4 deletions

View File

@ -8,7 +8,6 @@ import (
"reflect"
"strconv"
"sync"
"syscall"
"time"
"github.com/hashicorp/consul/lib/file"
@ -255,9 +254,9 @@ func (p *Daemon) start() (*os.Process, error) {
cmd.Args = []string{cmd.Path}
}
// Start it in a new sessions (and hence process group) so that killing agent
// (even with Ctrl-C) won't kill proxy.
cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
// Perform system-specific setup. In particular, Unix-like systems
// shuld set sid so that killing the agent doesn't kill the daemon.
configureDaemon(&cmd)
// Start it
p.Logger.Printf("[DEBUG] agent/proxy: starting proxy: %q %#v", cmd.Path, cmd.Args[1:])

View File

@ -5,6 +5,7 @@ package proxy
import (
"fmt"
"os"
"os/exec"
"syscall"
)
@ -28,3 +29,10 @@ func findProcess(pid int) (*os.Process, error) {
return nil, fmt.Errorf("process %d is dead or running as another user", pid)
}
// configureDaemon is called prior to Start to allow system-specific setup.
func configureDaemon(cmd *exec.Cmd) {
// Start it in a new sessions (and hence process group) so that killing agent
// (even with Ctrl-C) won't kill proxy.
cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
}

View File

@ -4,6 +4,7 @@ package proxy
import (
"os"
"os/exec"
)
func findProcess(pid int) (*os.Process, error) {
@ -12,3 +13,7 @@ func findProcess(pid int) (*os.Process, error) {
// non-nil means it seems to be healthy.
return os.FindProcess(pid)
}
func configureDaemon(cmd *exec.Cmd) {
// Do nothing
}