Skip to content

Commit 13ea4f4

Browse files
committed
stopVMM: ignore "process already finished"
Falling back to the first idea: instead of racing to see if the process is finished, always signal, and ignore the instances where the signal wasn't needed. Signed-off-by: Peter Wagner <[email protected]>
1 parent 04acce5 commit 13ea4f4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

machine.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"os/signal"
2424
"path/filepath"
2525
"strconv"
26+
"strings"
2627
"sync"
2728
"syscall"
2829
"time"
@@ -576,9 +577,13 @@ func (m *Machine) StopVMM() error {
576577
}
577578

578579
func (m *Machine) stopVMM() error {
579-
if m.cmd != nil && m.cmd.Process != nil && m.cmd.ProcessState == nil {
580+
if m.cmd != nil && m.cmd.Process != nil {
580581
m.logger.Debug("stopVMM(): sending sigterm to firecracker")
581-
return m.cmd.Process.Signal(syscall.SIGTERM)
582+
err := m.cmd.Process.Signal(syscall.SIGTERM)
583+
if err != nil && !strings.Contains(err.Error(), "os: process already finished") {
584+
return err
585+
}
586+
return nil
582587
}
583588
m.logger.Debug("stopVMM(): no firecracker process running, not sending a signal")
584589

0 commit comments

Comments
 (0)