Permalink
Browse files

Revert "Change popen calls to a block form to make sure we do not lea…

…ve zombies behind"

This reverts commit 3a8bb2c.
  • Loading branch information...
1 parent 534cf8a commit 365f1816f2a8e21254c724e3a254152cc6098a16 @gnarg gnarg committed Jan 16, 2012
Showing with 4 additions and 8 deletions.
  1. +3 −5 lib/new_relic/agent/samplers/memory_sampler.rb
  2. +1 −3 lib/new_relic/local_environment.rb
View
8 lib/new_relic/agent/samplers/memory_sampler.rb
@@ -124,11 +124,9 @@ class ProcStatus < Base
def get_memory
# We do not read the file directly because of a kernel bug in linux prior to 2.6.30
# that makes ruby IO hang on select() calls to /proc/* files forever
- File.popen("cat #{proc_status_file}") do |pipe|
- pipe.readlines.each do |line|
- if line =~ /RSS:\s*(\d+) kB/i
- return $1.to_f / 1024.0
- end
+ File.popen("cat #{proc_status_file}").readlines.each do |line|
+ if line =~ /RSS:\s*(\d+) kB/i
+ return $1.to_f / 1024.0
end
end
raise "Unable to find RSS in #{proc_status_file}"
View
4 lib/new_relic/local_environment.rb
@@ -108,9 +108,7 @@ def gather_cpu_info
@processors = append_environment_value('Processors') do
# We do not read the file directly because of a kernel bug in linux prior to 2.6.30
# that makes ruby IO hang on select() calls to /proc/* files forever
- processors = File.popen('cat /proc/cpuinfo') do |pipe|
- pipe.readlines.select { |line| line =~ /^processor\s*:/ }.size
- end
+ processors = File.popen('cat /proc/cpuinfo').readlines.select { |line| line =~ /^processor\s*:/ }.size
raise "Cannot determine the number of processors in /proc/cpuinfo" unless processors > 0
processors
end

0 comments on commit 365f181

Please sign in to comment.