From a468d955bca1f28f241555d2c631661982e699b5 Mon Sep 17 00:00:00 2001 From: Cyrill Troxler Date: Mon, 23 Jul 2018 20:26:42 +0200 Subject: [PATCH] Check for defunct process before waiting for it --- pkg/s3/util.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/pkg/s3/util.go b/pkg/s3/util.go index c1b37fe..87f1c96 100644 --- a/pkg/s3/util.go +++ b/pkg/s3/util.go @@ -17,6 +17,18 @@ func waitForProcess(p *os.Process, backoff int) error { if backoff == 20 { return fmt.Errorf("Timeout waiting for PID %v to end", p.Pid) } + cmdLine, err := getCmdLine(p.Pid) + if err != nil { + glog.Warningf("Error checking cmdline of PID %v, assuming it is dead: %s", p.Pid, err) + return nil + } + if cmdLine == "" { + // ignore defunct processes + // TODO: debug why this happens in the first place + // seems to only happen on k8s, not on local docker + glog.Warning("Fuse process seems dead, returning") + return nil + } if err := p.Signal(syscall.Signal(0)); err != nil { glog.Warningf("Fuse process does not seem active or we are unprivileged: %s", err) return nil @@ -38,12 +50,6 @@ func findFuseMountProcess(path string, name string) (*os.Process, error) { glog.Errorf("Unable to get cmdline of PID %v: %s", p.Pid(), err) continue } - if cmdLine == "" { - // ignore defunct processes - // TODO: debug why this happens in the first place - // seems to only happen on k8s, not on local docker - continue - } if strings.Contains(cmdLine, path) { glog.Infof("Found matching pid %v on path %s", p.Pid(), path) return os.FindProcess(p.Pid())