19 lines
299 B
Go
19 lines
299 B
Go
|
|
//go:build !windows
|
||
|
|
|
||
|
|
package forwarder
|
||
|
|
|
||
|
|
import (
|
||
|
|
"errors"
|
||
|
|
"os"
|
||
|
|
"syscall"
|
||
|
|
)
|
||
|
|
|
||
|
|
func processExists(pid int) bool {
|
||
|
|
process, err := os.FindProcess(pid)
|
||
|
|
if err != nil || process == nil {
|
||
|
|
return false
|
||
|
|
}
|
||
|
|
err = process.Signal(syscall.Signal(0))
|
||
|
|
return err == nil || errors.Is(err, syscall.EPERM)
|
||
|
|
}
|