From 618666ed8c649df66062d83b13ba0cb26ab5940d Mon Sep 17 00:00:00 2001 From: Ted Yu Date: Tue, 19 Nov 2019 05:46:20 -0800 Subject: [PATCH] vc: Remove unnecessary call to kill Fixes #2207 Signed-off-by: Ted Yu --- virtcontainers/acrn.go | 10 +++------- virtcontainers/fc.go | 9 +++------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/virtcontainers/acrn.go b/virtcontainers/acrn.go index a734a7ab92..5787a25f46 100644 --- a/virtcontainers/acrn.go +++ b/virtcontainers/acrn.go @@ -513,15 +513,11 @@ func (a *Acrn) stopSandbox() (err error) { pid := a.state.PID - // Check if VM process is running, in case it is not, let's - // return from here. - if err = syscall.Kill(pid, syscall.Signal(0)); err != nil { - a.Logger().Info("acrn VM already stopped") - return nil - } - // Send signal to the VM process to try to stop it properly if err = syscall.Kill(pid, syscall.SIGINT); err != nil { + if err == syscall.ESRCH { + return nil + } a.Logger().Info("Sending signal to stop acrn VM failed") return err } diff --git a/virtcontainers/fc.go b/virtcontainers/fc.go index e6fdb0a307..77673b8632 100644 --- a/virtcontainers/fc.go +++ b/virtcontainers/fc.go @@ -467,14 +467,11 @@ func (fc *firecracker) fcEnd() (err error) { pid := fc.info.PID - // Check if VM process is running, in case it is not, let's - // return from here. - if err = syscall.Kill(pid, syscall.Signal(0)); err != nil { - return nil - } - // Send a SIGTERM to the VM process to try to stop it properly if err = syscall.Kill(pid, syscall.SIGTERM); err != nil { + if err == syscall.ESRCH { + return nil + } return err }