Files
podman/pkg/machine/gvproxy_unix.go
Brent Baude 9e680cbc63 Fixups for stopping gvproxy
Paul found logic errors in my earlier code for finding processes and
sending signals.  Some of the logic errors are associated with how
methods behave on different operating systems.  Created a darwin and
linux approach and a windows approach.

Signed-off-by: Brent Baude <bbaude@redhat.com>

[NO NEW TESTS NEEDED]
2023-08-22 16:00:15 -05:00

25 lines
582 B
Go

//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd
// +build darwin dragonfly freebsd linux netbsd openbsd
package machine
import (
"os"
"syscall"
)
func findProcess(pid int) (*os.Process, error) {
p, err := os.FindProcess(pid)
if err != nil {
return nil, err
}
// On unix, findprocess will always return a process even
// if the process is not found. you must send a 0 signal
// to the process to see if it is alive.
// https://pkg.go.dev/os#FindProcess
if err := p.Signal(syscall.Signal(0)); err != nil {
return nil, err
}
return p, nil
}