From a7b22031cdbe8555ef6d4a086bd11dbc9feea4fd Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 28 Jun 2024 13:46:53 +0200 Subject: vmimpl: add a delay after an error from the tracked process It usually means a kernel crash, in which case we want to give the kernel some more time to print the whole coverage report to the console. --- vm/vmimpl/vmimpl.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'vm/vmimpl') diff --git a/vm/vmimpl/vmimpl.go b/vm/vmimpl/vmimpl.go index be7186889..00a815314 100644 --- a/vm/vmimpl/vmimpl.go +++ b/vm/vmimpl/vmimpl.go @@ -146,6 +146,8 @@ var ( Types = make(map[string]Type) ) +var WaitForOutputTimeout = 10 * time.Second + func Multiplex(cmd *exec.Cmd, merger *OutputMerger, console io.Closer, timeout time.Duration, stop, closed <-chan bool, debug bool) (<-chan []byte, <-chan error, error) { errc := make(chan error, 1) @@ -168,6 +170,9 @@ func Multiplex(cmd *exec.Cmd, merger *OutputMerger, console io.Closer, timeout t signal(fmt.Errorf("instance closed")) case err := <-merger.Err: cmd.Process.Kill() + // Once the command has exited, we might want to let the full console + // output accumulate before we abort the console connection too. + time.Sleep(WaitForOutputTimeout) if console != nil { // Only wait for the merger if we're able to control the console stream. console.Close() -- cgit mrf-deployment