mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
move process terminate operation to defer function
Signed-off-by: lifubang <lifubang@acmcoder.com>
This commit is contained in:
+6
-5
@@ -286,22 +286,23 @@ func (r *runner) run(config *specs.Process) (_ int, retErr error) {
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
defer func() {
|
||||
// We should terminate the process once we got an error.
|
||||
if retErr != nil {
|
||||
r.terminate(process)
|
||||
}
|
||||
}()
|
||||
if err = tty.waitConsole(); err != nil {
|
||||
r.terminate(process)
|
||||
return -1, err
|
||||
}
|
||||
tty.ClosePostStart()
|
||||
if r.pidFile != "" {
|
||||
if err = createPidFile(r.pidFile, process); err != nil {
|
||||
r.terminate(process)
|
||||
return -1, err
|
||||
}
|
||||
}
|
||||
handler := <-handlerCh
|
||||
status, err := handler.forward(process, tty, detach)
|
||||
if err != nil {
|
||||
r.terminate(process)
|
||||
}
|
||||
if detach {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user