diff --git a/agent/proxy/daemon.go b/agent/proxy/daemon.go index e9bf318a2..7a15b12ab 100644 --- a/agent/proxy/daemon.go +++ b/agent/proxy/daemon.go @@ -284,6 +284,7 @@ func (p *Daemon) Stop() error { // used only for tests. func (p *Daemon) stopKeepAlive() error { p.lock.Lock() + defer p.lock.Unlock() // If we're already stopped or never started, then no problem. if p.stopped || p.process == nil { @@ -295,7 +296,6 @@ func (p *Daemon) stopKeepAlive() error { // Note that we've stopped p.stopped = true close(p.stopCh) - p.lock.Unlock() return nil } diff --git a/agent/proxy/process_unix.go b/agent/proxy/process_unix.go index deb45d080..9bca07c2b 100644 --- a/agent/proxy/process_unix.go +++ b/agent/proxy/process_unix.go @@ -22,9 +22,9 @@ func findProcess(pid int) (*os.Process, error) { // a 0 signal. This will do nothing to the process but will still // return errors if the process is gone. err = p.Signal(syscall.Signal(0)) - if err == nil || err == syscall.EPERM { + if err == nil { return p, nil } - return nil, fmt.Errorf("process is dead") + return nil, fmt.Errorf("process %d is dead or running as another user", pid) }