Skip to content

Commit

Permalink
Merge pull request #337 from andrewkroh/bugfix/procs-fd-leak
Browse files Browse the repository at this point in the history
Fix process monitoring FD leak
  • Loading branch information
monicasarbu committed Oct 26, 2015
2 parents c42da7c + 282ebf9 commit 935d381
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file based on the
### Backward Compatibility Breaks

### Bugfixes
- Close file descriptors used to monitor processes. #337

### Added

Expand Down
3 changes: 3 additions & 0 deletions procs/procs.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ func FindPidsByCmdlineGrep(prefix string, process string) ([]int, error) {
if err != nil {
return pids, fmt.Errorf("Open /proc: %s", err)
}
defer proc.Close()

names, err := proc.Readdirnames(0)
if err != nil {
Expand Down Expand Up @@ -271,6 +272,7 @@ func (proc *ProcessesWatcher) UpdateMap() {
logp.Err("Open: %s", err)
return
}
defer file.Close()
socks, err := Parse_Proc_Net_Tcp(file)
if err != nil {
logp.Err("Parse_Proc_Net_Tcp: %s", err)
Expand Down Expand Up @@ -365,6 +367,7 @@ func FindSocketsOfPid(prefix string, pid int) (inodes []int64, err error) {
if err != nil {
return []int64{}, fmt.Errorf("Open: %s", err)
}
defer procfs.Close()
names, err := procfs.Readdirnames(0)
if err != nil {
return []int64{}, fmt.Errorf("Readdirnames: %s", err)
Expand Down

0 comments on commit 935d381

Please sign in to comment.