Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion internal/core/runner/output_capture.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

package runner

import (
Expand Down Expand Up @@ -55,8 +56,11 @@ func (s *OutputCaptureRunner) CaptureOutput(cmd *exec.Cmd) error {
if timeout == 0 {
timeout = 5 * time.Second
}
wgTimer := sync.WaitGroup{}
wgTimer.Add(1)

timer := time.AfterFunc(timeout, func() {
defer wgTimer.Done()
if cmd != nil && cmd.Process != nil {
// write the error
s.WriteError([]byte("error: timeout\n"))
Expand Down Expand Up @@ -154,7 +158,10 @@ func (s *OutputCaptureRunner) CaptureOutput(cmd *exec.Cmd) error {
}

// stop the timer
timer.Stop()
if !timer.Stop(){
// timer already triggered
wgTimer.Wait()
}

s.done <- true
}()
Expand Down