Adds the ownership check as a dependency

Otherway I see no obvious way to pass this check
during (say) unit testing
pull/15782/head
x7upLime 2023-03-22 22:07:44 +01:00
parent 9665bad429
commit c55a4caacc
1 changed files with 6 additions and 4 deletions

View File

@ -622,7 +622,7 @@ func killProcess(path string) error {
// error handling is done below
var errs []error
for _, pp := range ppp {
err := trySigKillProcess(pp)
err := trySigKillProcess(pp, doesPIDBelongToMinikube)
if err != nil {
errs = append(errs, err)
}
@ -649,9 +649,11 @@ func killProcess(path string) error {
return err
}
// trySigKillProcess takes a PID as argument and tries to SIGKILL it
func trySigKillProcess(pid int) error {
itDoes, err := doesPIDBelongToMinikube(pid)
// trySigKillProcess takes a PID as argument and tries to SIGKILL it.
// It performs the OCHECK ownership check of the pid,
// before trying to send a sigkill signal to it
func trySigKillProcess(pid int, ocheck func(int) (bool, error)) error {
itDoes, err := ocheck(pid)
if err != nil {
return err
}