Skip to content

Commit

Permalink
try to support windows
Browse files Browse the repository at this point in the history
  • Loading branch information
whyrusleeping committed Dec 6, 2015
1 parent 704b0dc commit b21f95b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
9 changes: 8 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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++ {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
13 changes: 13 additions & 0 deletions proc_unix.go
Original file line number Diff line number Diff line change
@@ -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}
}
}

0 comments on commit b21f95b

Please sign in to comment.