From bf735a2e861d6b1c686dd4a076afc3468aa89c4a Mon Sep 17 00:00:00 2001 From: Michael Weibel <307427+mweibel@users.noreply.github.com> Date: Fri, 13 Oct 2023 13:48:19 +0200 Subject: [PATCH] fix(windows): prevent infinite run. Fixes #11810 (#11993) Signed-off-by: Michael Weibel --- workflow/executor/os-specific/command.go | 15 --------------- workflow/executor/os-specific/command_unix.go | 14 ++++++++++++++ workflow/executor/os-specific/command_windows.go | 11 +++++++++++ 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/workflow/executor/os-specific/command.go b/workflow/executor/os-specific/command.go index 3e636babcd77..5d59672104eb 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 4f6090f92541..5c8a8814ef6c 100644 --- a/workflow/executor/os-specific/command_unix.go +++ b/workflow/executor/os-specific/command_unix.go @@ -9,6 +9,7 @@ import ( "os/exec" "os/signal" "syscall" + "time" "github.com/creack/pty" "golang.org/x/term" @@ -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 +} diff --git a/workflow/executor/os-specific/command_windows.go b/workflow/executor/os-specific/command_windows.go index 5caf0d6ad2f8..4dd9f575d9f7 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 +}