Skip to content

Commit

Permalink
Handle process termination during read from /proc
Browse files Browse the repository at this point in the history
  • Loading branch information
solita-timo-mihaljov committed May 16, 2017
1 parent bfeb302 commit 303a79f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions plugins/inputs/system/processes.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"path/filepath"
"runtime"
"strconv"
"syscall"

"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins/inputs"
Expand Down Expand Up @@ -195,6 +196,13 @@ func readProcFile(filename string) ([]byte, error) {
if os.IsNotExist(err) {
return nil, nil
}

// Reading from /proc/<PID> fails with ESRCH if the process has
// been terminated between open() and read().
if perr, ok := err.(*os.PathError); ok && perr.Err == syscall.ESRCH {
return nil, nil
}

return nil, err
}

Expand Down

0 comments on commit 303a79f

Please sign in to comment.