From b21f95b87a2275911fda072ee916dd2da72b436a Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sun, 6 Dec 2015 11:24:15 -0800 Subject: [PATCH] try to support windows --- main.go | 9 ++++++++- proc_unix.go | 13 +++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 proc_unix.go diff --git a/main.go b/main.go index 3a038ed..c48a6fe 100644 --- a/main.go +++ b/main.go @@ -23,6 +23,8 @@ import ( ma "github.com/jbenet/go-multiaddr-net/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" ) +var setupOpt = func(cmd *exec.Cmd) {} + // GetNumNodes returns the number of testbed nodes configured in the testbed directory func GetNumNodes() int { for i := 0; i < 2000; i++ { @@ -279,7 +281,7 @@ func IpfsStart(waitall bool) error { cmd.Dir = dir cmd.Env = envForDaemon(i) - cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true} + setupOpt(cmd) stdout, err := os.Create(path.Join(dir, "daemon.stdout")) if err != nil { @@ -602,6 +604,11 @@ func main() { kingpin.Arg("args", "arguments").StringsVar(&args) kingpin.Parse() + if len(args) == 0 { + kingpin.Usage() + return + } + switch args[0] { case "init": if cfg.Count == 0 { diff --git a/proc_unix.go b/proc_unix.go new file mode 100644 index 0000000..48d2717 --- /dev/null +++ b/proc_unix.go @@ -0,0 +1,13 @@ +// +build !windows +package main + +import ( + "os/exec" + "syscall" +) + +func init() { + setupOpt = func(cmd *exec.Cmd) { + cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true} + } +}