Initial commit
This commit is contained in:
16
vendor/go.i3wm.org/i3/validpid.go
generated
vendored
Normal file
16
vendor/go.i3wm.org/i3/validpid.go
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
package i3
|
||||
|
||||
import "syscall"
|
||||
|
||||
func pidValid(pid int) bool {
|
||||
// As per kill(2) from POSIX.1-2008, sending signal 0 validates a pid.
|
||||
if err := syscall.Kill(pid, 0); err != nil {
|
||||
if err == syscall.EPERM {
|
||||
// Process still alive (but no permission to signal):
|
||||
return true
|
||||
}
|
||||
// errno is likely ESRCH (process not found).
|
||||
return false // Process not alive.
|
||||
}
|
||||
return true // Process still alive.
|
||||
}
|
||||
Reference in New Issue
Block a user