From 4ef9bf5c8428fcf1ea6db0cb3c9d339ec58a234d Mon Sep 17 00:00:00 2001 From: John Howard Date: Tue, 15 Jan 2019 10:44:18 -0800 Subject: [PATCH] Windows: Publish exit status correctly in TaskExit Signed-off-by: John Howard Before this change, the shim was only publishing a non-zero exit status (exit code) in the case that the process.Wait() call failed. This grabs the exit status correctly when process.Wait() succeeds too. --- runtime/v2/runhcs/process.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/runtime/v2/runhcs/process.go b/runtime/v2/runhcs/process.go index 7b475a504..0b3a395fe 100644 --- a/runtime/v2/runhcs/process.go +++ b/runtime/v2/runhcs/process.go @@ -21,7 +21,6 @@ package runhcs import ( "context" "os" - "os/exec" "sync" "sync/atomic" "syscall" @@ -69,15 +68,14 @@ func waitForProcess(ctx context.Context, process *process, p *os.Process, s *ser }) var status int - _, eerr := p.Wait() + processState, eerr := p.Wait() if eerr != nil { status = 255 - if exitErr, ok := eerr.(*exec.ExitError); ok { - if ws, ok := exitErr.Sys().(syscall.WaitStatus); ok { - status = ws.ExitStatus() - } - } + p.Kill() + } else { + status = processState.Sys().(syscall.WaitStatus).ExitStatus() } + now := time.Now() process.exit.Store(&processExit{ pid: pid,