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 }