-
Notifications
You must be signed in to change notification settings - Fork 253
Open
Description
I noticed that the search function doesn't actually test whether a process is alive or not. According to the docs for os.FindProcess(pid) this will never be nil on Unix systems even when a process doesn't exist.
On Unix systems, FindProcess always succeeds and returns a Process for the given pid, regardless of whether the process exists.
This was giving me issues on my Linux machine without this patch, so I have submitted a pull request to fix this. It complains I've not hit some checks or something. I've never submitted a PR to an open source project on any repository ever, so my apologies that I don't know what I am doing for that.
New search code for daemon_unix.go
func (d *Context) search() (daemon *os.Process, err error) {
if len(d.PidFileName) > 0 {
var pid int
if pid, err = ReadPidFile(d.PidFileName); err != nil {
return
}
daemon, err = os.FindProcess(pid)
if err == nil && daemon != nil {
// Truly check on Unix systems that the daemon is running
// Daemon is not actually running if an error is received
if daemon.Signal(syscall.Signal(0)) != nil {
daemon = nil
}
}
}
return
}Metadata
Metadata
Assignees
Labels
No labels