Skip to content
Snippets Groups Projects
Commit c53d9fa9 authored by Timo Mihaljov's avatar Timo Mihaljov Committed by Daniel Nelson
Browse files

Handle process termination during read from /proc (#2816)

Fixes #2815.
parent ac5ac316
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,7 @@ import ( ...@@ -12,6 +12,7 @@ import (
"path/filepath" "path/filepath"
"runtime" "runtime"
"strconv" "strconv"
"syscall"
"github.com/influxdata/telegraf" "github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/inputs"
...@@ -195,6 +196,13 @@ func readProcFile(filename string) ([]byte, error) { ...@@ -195,6 +196,13 @@ func readProcFile(filename string) ([]byte, error) {
if os.IsNotExist(err) { if os.IsNotExist(err) {
return nil, nil 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 return nil, err
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment