mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-10-25 09:03:17 +08:00
28 lines
537 B
Go
28 lines
537 B
Go
//go:build cgo && (linux || darwin || freebsd)
|
|
|
|
package pluginhost
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
"syscall"
|
|
)
|
|
|
|
func removeShadowPlugin(path string) {
|
|
if path == "" {
|
|
return
|
|
}
|
|
_ = os.Remove(path)
|
|
}
|
|
|
|
func removeShadowPluginDir(dir string) {
|
|
_ = os.RemoveAll(dir)
|
|
}
|
|
|
|
func shadowPluginProcessAlive(pid int) bool {
|
|
// Only ESRCH proves the process is gone; any other outcome keeps the
|
|
// directory so a live process never loses its resident plugin images.
|
|
errSignal := syscall.Kill(pid, 0)
|
|
return !errors.Is(errSignal, syscall.ESRCH)
|
|
}
|