diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index ddca06c5dab..783ecfedaf6 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -33,6 +33,8 @@ https://github.com/elastic/beats/compare/v5.0.0-rc1...master[Check the HEAD diff *Metricbeat* +- Fix high CPU usage on macOS when encountering processes with long command lines. {issue}2747[2747] + *Packetbeat* *Topbeat* diff --git a/glide.yaml b/glide.yaml index cc845e086e0..dc4f9a7975f 100644 --- a/glide.yaml +++ b/glide.yaml @@ -25,7 +25,7 @@ import: subpackages: - /difflib - package: github.com/elastic/gosigar - version: 2716c1fe855ee5c88eae707195e0688374458c92 + version: 286c817a8ced9b4206b891c81d874f8ec5fee866 - package: github.com/samuel/go-parser version: ca8abbf65d0e61dedf061f98bd3850f250e27539 - package: github.com/samuel/go-thrift diff --git a/vendor/github.com/elastic/gosigar/sigar_darwin.go b/vendor/github.com/elastic/gosigar/sigar_darwin.go index ed60ba04e35..3a9921cf61c 100644 --- a/vendor/github.com/elastic/gosigar/sigar_darwin.go +++ b/vendor/github.com/elastic/gosigar/sigar_darwin.go @@ -361,13 +361,19 @@ func kern_procargs(pid int, binary.Read(bbuf, binary.LittleEndian, &argc) path, err := bbuf.ReadBytes(0) + if err != nil { + return fmt.Errorf("Error reading the argv[0]: %v", err) + } if exe != nil { exe(string(chop(path))) } // skip trailing \0's for { - c, _ := bbuf.ReadByte() + c, err := bbuf.ReadByte() + if err != nil { + return fmt.Errorf("Error skipping nils: %v", err) + } if c != 0 { bbuf.UnreadByte() break // start of argv[0] @@ -379,6 +385,9 @@ func kern_procargs(pid int, if err == io.EOF { break } + if err != nil { + return fmt.Errorf("Error reading args: %v", err) + } if argv != nil { argv(string(chop(arg))) } @@ -395,6 +404,9 @@ func kern_procargs(pid int, if err == io.EOF || line[0] == 0 { break } + if err != nil { + return fmt.Errorf("Error reading args: %v", err) + } pair := bytes.SplitN(chop(line), delim, 2) env(string(pair[0]), string(pair[1])) }