Skip to content

Commit

Permalink
[Auditbeat] Cherry-pick elastic#9669 and elastic#9682 to 6.x: Skip pr…
Browse files Browse the repository at this point in the history
…ocesses that do not exist anymore (elastic#9688)

A process can exit just after we get a list of PIDs, but before we get around to reading that process. This skips such processes as if we had not seen their PID in the first place.

(cherry picked from commit 2a859fb)
(cherry picked from commit 3702f16)
  • Loading branch information
Christoph Wurm authored Dec 19, 2018
1 parent d986b49 commit 3d38431
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions x-pack/auditbeat/module/system/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,22 @@ func (ms *MetricSet) getProcessInfos() ([]*ProcessInfo, error) {
for _, pid := range pids {
process, err := sysinfo.Process(pid)
if err != nil {
if os.IsNotExist(err) {
// Skip - process probably just terminated since our call
// to Pids()
continue
}
return nil, errors.Wrap(err, "failed to load process")
}

pInfo, err := process.Info()
if err != nil {
if os.IsNotExist(err) {
// Skip - process probably just terminated since our call
// to Pids()
continue
}

if os.Geteuid() != 0 {
if os.IsPermission(err) || runtime.GOOS == "darwin" {
/*
Expand Down

0 comments on commit 3d38431

Please sign in to comment.