Skip to content

Commit

Permalink
Merge pull request #1051 from ava-labs/kill-vm-after-handshake
Browse files Browse the repository at this point in the history
use kill to terminate vm process after rpc protocol query
  • Loading branch information
felipemadero authored Sep 21, 2023
2 parents 1854f57 + ecf8c73 commit dff77d5
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions pkg/vm/compatibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"io"
"path/filepath"
"strconv"
"syscall"
"time"

pb "github.com/ava-labs/avalanchego/proto/pb/vm/runtime"
Expand Down Expand Up @@ -113,14 +112,10 @@ func GetVMBinaryProtocolVersion(vmPath string) (int, error) {
return 0, fmt.Errorf("timeout while waiting for vm protocol version: %w", runtime.ErrHandshakeFailed)
}

if err := cmd.Process.Signal(syscall.SIGTERM); err != nil {
// no need for a clean process termination
if err := cmd.Process.Kill(); err != nil {
_ = dumpProcessOutput(stdoutPipe, stderrPipe)
return 0, fmt.Errorf("failure signaling termination to vm: %w", err)
}

if err := cmd.Wait(); err != nil {
_ = dumpProcessOutput(stdoutPipe, stderrPipe)
return 0, fmt.Errorf("failure waiting for vm termination: %w", err)
return 0, fmt.Errorf("failure killing vm: %w", err)
}

return int(protocolVersion), nil
Expand Down

0 comments on commit dff77d5

Please sign in to comment.