add windows support (#193)
* add windows support * build for win * fix win build
This commit is contained in:
parent
2482fd67c7
commit
d2b002000e
7 changed files with 74 additions and 16 deletions
|
|
@ -1,4 +1,4 @@
|
|||
//go:build !linux
|
||||
//go:build !linux && !windows
|
||||
|
||||
package main
|
||||
|
||||
|
|
@ -6,3 +6,7 @@ import "os/exec"
|
|||
|
||||
func setPdeathsig(cmd *exec.Cmd) {
|
||||
}
|
||||
|
||||
func addProcessToJob(cmd *exec.Cmd) error {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,3 +10,7 @@ import (
|
|||
func setPdeathsig(cmd *exec.Cmd) {
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{Pdeathsig: syscall.SIGTERM}
|
||||
}
|
||||
|
||||
func addProcessToJob(cmd *exec.Cmd) error {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
35
cmd/sshpiperd/cmd_windows.go
Normal file
35
cmd/sshpiperd/cmd_windows.go
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
//go:build windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/tg123/jobobject"
|
||||
)
|
||||
|
||||
func setPdeathsig(cmd *exec.Cmd) {
|
||||
}
|
||||
|
||||
func addProcessToJob(cmd *exec.Cmd) error {
|
||||
if jobObject == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if cmd.Process == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return jobObject.AddProcess(cmd.Process)
|
||||
}
|
||||
|
||||
var jobObject *jobobject.JobObject
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
jobObject, err = jobobject.Create()
|
||||
if err != nil {
|
||||
log.Warnf("failed to create job object: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
@ -62,6 +62,10 @@ func createCmdPlugin(args []string) (*plugin.CmdPlugin, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if err := addProcessToJob(cmd); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
p.Name = exe
|
||||
|
||||
return p, nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue