Call process.Wait to reap children

This commit is contained in:
Vitaliy Filippov 2021-07-19 19:43:32 +03:00
parent 55013c94bc
commit 4ba5ca319b

View file

@ -134,22 +134,23 @@ func waitForProcess(p *os.Process, limit int) error {
cmdLine, err := getCmdLine(p.Pid) cmdLine, err := getCmdLine(p.Pid)
if err != nil { if err != nil {
glog.Warningf("Error checking cmdline of PID %v, assuming it is dead: %s", p.Pid, err) glog.Warningf("Error checking cmdline of PID %v, assuming it is dead: %s", p.Pid, err)
p.Wait()
return nil return nil
} }
if cmdLine == "" { 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") glog.Warning("Fuse process seems dead, returning")
p.Wait()
return nil return nil
} }
if err := p.Signal(syscall.Signal(0)); err != nil { if err := p.Signal(syscall.Signal(0)); err != nil {
glog.Warningf("Fuse process does not seem active or we are unprivileged: %s", err) glog.Warningf("Fuse process does not seem active or we are unprivileged: %s", err)
p.Wait()
return nil return nil
} }
glog.Infof("Fuse process with PID %v still active, waiting...", p.Pid) glog.Infof("Fuse process with PID %v still active, waiting...", p.Pid)
time.Sleep(time.Duration(math.Pow(1.5, float64(backoff))*100) * time.Millisecond) time.Sleep(time.Duration(math.Pow(1.5, float64(backoff))*100) * time.Millisecond)
} }
p.Release()
return fmt.Errorf("Timeout waiting for PID %v to end", p.Pid) return fmt.Errorf("Timeout waiting for PID %v to end", p.Pid)
} }