Skip to content

Commit

Permalink
vc: Remove unnecessary call to kill
Browse files Browse the repository at this point in the history
Fixes kata-containers#2207

Signed-off-by: Ted Yu <yuzhihong@gmail.com>
  • Loading branch information
yutedz committed Nov 19, 2019
1 parent c0d2867 commit 618666e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
10 changes: 3 additions & 7 deletions virtcontainers/acrn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
9 changes: 3 additions & 6 deletions virtcontainers/fc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 618666e

Please sign in to comment.