github.com/hashicorp/go-plugin@v1.6.0/internal/cmdrunner/process_posix.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  //go:build !windows
     5  // +build !windows
     6  
     7  package cmdrunner
     8  
     9  import (
    10  	"os"
    11  	"syscall"
    12  )
    13  
    14  // _pidAlive tests whether a process is alive or not by sending it Signal 0,
    15  // since Go otherwise has no way to test this.
    16  func _pidAlive(pid int) bool {
    17  	proc, err := os.FindProcess(pid)
    18  	if err == nil {
    19  		err = proc.Signal(syscall.Signal(0))
    20  	}
    21  
    22  	return err == nil
    23  }