From 66e474aacf40a660fec7343e68e4a6e83cd0be90 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 Oct 2023 12:54:33 +0200 Subject: [PATCH] fix(windows): prevent infinite run. Fixes #11810 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 --- workflow/executor/os-specific/command.go | 15 --------------- workflow/executor/os-specific/command_unix.go | 13 +++++++++++++ workflow/executor/os-specific/command_windows.go | 11 +++++++++++ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/workflow/executor/os-specific/command.go b/workflow/executor/os-specific/command.go index 3e636babcd77c..5d59672104eb5 100644 --- a/workflow/executor/os-specific/command.go +++ b/workflow/executor/os-specific/command.go @@ -3,8 +3,6 @@ package os_specific import ( "io" "os" - "os/exec" - "time" log "github.com/sirupsen/logrus" "golang.org/x/term" @@ -12,19 +10,6 @@ import ( 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())) diff --git a/workflow/executor/os-specific/command_unix.go b/workflow/executor/os-specific/command_unix.go index 4f6090f92541d..a5c29fc05c38b 100644 --- a/workflow/executor/os-specific/command_unix.go +++ b/workflow/executor/os-specific/command_unix.go @@ -88,3 +88,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 +} diff --git a/workflow/executor/os-specific/command_windows.go b/workflow/executor/os-specific/command_windows.go index 5caf0d6ad2f86..4dd9f575d9f7c 100644 --- a/workflow/executor/os-specific/command_windows.go +++ b/workflow/executor/os-specific/command_windows.go @@ -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 +}