testtask: Build on windows
This commit is contained in:
parent
2656f28f08
commit
96b1d5d20c
|
@ -7,8 +7,6 @@ import (
|
|||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
|
@ -115,21 +113,11 @@ func execute() {
|
|||
ioutil.WriteFile(file, []byte(msg), 0666)
|
||||
|
||||
case "pgrp":
|
||||
// pgrp <group_int> puts the pid in a new process group
|
||||
if len(args) < 1 {
|
||||
fmt.Fprintln(os.Stderr, "expected process group number for pgrp")
|
||||
os.Exit(1)
|
||||
}
|
||||
num := popArg()
|
||||
grp, err := strconv.Atoi(num)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "failed to convert process group number %q: %v\n", num, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if err := syscall.Setpgid(0, grp); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "failed to set process group: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
executeProcessGroup(popArg())
|
||||
|
||||
case "fork/exec":
|
||||
// fork/exec <pid_file> <args> forks execs the helper process
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
// +build unix
|
||||
|
||||
package testtask
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func executeProcessGroup(gid string) {
|
||||
// pgrp <group_int> puts the pid in a new process group
|
||||
grp, err := strconv.Atoi(gid)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "failed to convert process group number %q: %v\n", gid, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if err := syscall.Setpgid(0, grp); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "failed to set process group: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
// +build windows
|
||||
|
||||
package testtask
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func executeProcessGroup(gid string) {
|
||||
fmt.Fprintf(os.Stderr, "process groups are not supported on windows\n")
|
||||
os.Exit(1)
|
||||
}
|
Loading…
Reference in New Issue