ajhahn.de
← eeco
Go 35 lines
//go:build !windows

package queue

import (
	"errors"
	"syscall"
)

// processAlive reports whether the given pid currently exists. A pid
// of an exited process returns ESRCH from kill(pid, 0); any other
// error (notably EPERM, which still proves the pid is alive but
// owned by another user) is treated as alive.
func processAlive(pid int) bool {
	if pid <= 0 {
		return false
	}
	err := syscall.Kill(pid, 0)
	if err == nil {
		return true
	}
	if errors.Is(err, syscall.ESRCH) {
		return false
	}
	return true
}

// isPendingDelete reports whether err is the transient Windows "delete
// pending" rejection of an exclusive create (see the windows build's
// implementation). No equivalent state exists on Unix, so it is always
// false here and tryClaim's create runs exactly once.
func isPendingDelete(error) bool {
	return false
}