Skip to content

Commit

Permalink
fix(windows): prevent infinite run. Fixes #11810
Browse files Browse the repository at this point in the history
windows based workflows already call .Wait() in signal_windows.go,
calling it twice will result in not exiting at all.

Unix based workflows prevent that by releasing the process early on
and checking exit code of all running processes.

Windows workflows don't do this and without knowing in-depth how windows
processes work, I didn't find a way to achieve a similar "wait for all
processes" syscall.

Signed-off-by: Michael Weibel <michael@helio.exchange>
  • Loading branch information
mweibel committed Oct 13, 2023
1 parent 96d9643 commit 052c8b0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
15 changes: 0 additions & 15 deletions workflow/executor/os-specific/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,13 @@ package os_specific
import (
"io"
"os"
"os/exec"
"time"

log "github.com/sirupsen/logrus"
"golang.org/x/term"
)

var logger = log.WithField("argo", true)

func simpleStart(cmd *exec.Cmd) (func(), error) {
if err := cmd.Start(); err != nil {
return nil, err
}

closer := func() {
cmd.WaitDelay = 100 * time.Millisecond
_ = cmd.Wait()
}

return closer, nil
}

func isTerminal(stdin io.Reader) bool {
f, ok := stdin.(*os.File)
return ok && term.IsTerminal(int(f.Fd()))
Expand Down
14 changes: 14 additions & 0 deletions workflow/executor/os-specific/command_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os/exec"
"os/signal"
"syscall"
"time"

"github.com/creack/pty"
"golang.org/x/term"
Expand Down Expand Up @@ -88,3 +89,16 @@ func StartCommand(cmd *exec.Cmd) (func(), error) {

return closer, nil
}

func simpleStart(cmd *exec.Cmd) (func(), error) {
if err := cmd.Start(); err != nil {
return nil, err
}

closer := func() {
cmd.WaitDelay = 100 * time.Millisecond
_ = cmd.Wait()
}

return closer, nil
}
11 changes: 11 additions & 0 deletions workflow/executor/os-specific/command_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,14 @@ func StartCommand(cmd *exec.Cmd) (func(), error) {
}
return simpleStart(cmd)
}

func simpleStart(cmd *exec.Cmd) (func(), error) {
if err := cmd.Start(); err != nil {
return nil, err
}

closer := func() {
}

return closer, nil
}

0 comments on commit 052c8b0

Please sign in to comment.