summaryrefslogtreecommitdiff
path: root/worker.go
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-01-28 14:28:52 +0300
committerWolfy-J <[email protected]>2018-01-28 14:28:52 +0300
commite4e5cadce7deef4c36c038a4900d55ea30dd099c (patch)
treeda174e9e19a9df3b3800fc9a61b2595fd69c1336 /worker.go
parentf060cf750fcdbce0cbc8621f87af1dfd1520e748 (diff)
windows support
Diffstat (limited to 'worker.go')
-rw-r--r--worker.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/worker.go b/worker.go
index d581481f..851239f9 100644
--- a/worker.go
+++ b/worker.go
@@ -7,6 +7,7 @@ import (
"github.com/spiral/goridge"
"os"
"os/exec"
+ "runtime"
"strconv"
"strings"
"sync"
@@ -100,17 +101,16 @@ func (w *Worker) Start() error {
w.Pid = &w.cmd.Process.Pid
- // relays for process to complete
+ // wait for process to complete
go func() {
w.endState, _ = w.cmd.Process.Wait()
if w.waitDone != nil {
w.state.set(StateStopped)
-
close(w.waitDone)
+
if w.rl != nil {
w.mu.Lock()
defer w.mu.Unlock()
-
w.rl.Close()
}
}
@@ -130,7 +130,11 @@ func (w *Worker) Wait() error {
w.mu.Lock()
defer w.mu.Unlock()
- w.cmd.Wait()
+ if runtime.GOOS != "windows" {
+ // windows handles processes and close pipes differently,
+ // we can ignore wait here as process.Wait() already being handled above
+ w.cmd.Wait()
+ }
if w.endState.Success() {
return nil
@@ -172,7 +176,7 @@ func (w *Worker) Kill() error {
defer w.mu.Unlock()
w.state.set(StateInactive)
- err := w.cmd.Process.Kill()
+ err := w.cmd.Process.Signal(os.Kill)
<-w.waitDone
return err