Merge pull request #2935 from jhowardmsft/jjh/rightexitcode
Windows: Publish exit status correctly in TaskExit
This commit is contained in:
commit
7d75a3f282
@ -21,7 +21,6 @@ package runhcs
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"syscall"
|
"syscall"
|
||||||
@ -69,15 +68,14 @@ func waitForProcess(ctx context.Context, process *process, p *os.Process, s *ser
|
|||||||
})
|
})
|
||||||
|
|
||||||
var status int
|
var status int
|
||||||
_, eerr := p.Wait()
|
processState, eerr := p.Wait()
|
||||||
if eerr != nil {
|
if eerr != nil {
|
||||||
status = 255
|
status = 255
|
||||||
if exitErr, ok := eerr.(*exec.ExitError); ok {
|
p.Kill()
|
||||||
if ws, ok := exitErr.Sys().(syscall.WaitStatus); ok {
|
} else {
|
||||||
status = ws.ExitStatus()
|
status = processState.Sys().(syscall.WaitStatus).ExitStatus()
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
process.exit.Store(&processExit{
|
process.exit.Store(&processExit{
|
||||||
pid: pid,
|
pid: pid,
|
||||||
|
Loading…
Reference in New Issue
Block a user