lib/instana/util.rb in instana-1.4.0 vs lib/instana/util.rb in instana-1.4.1

- old
+ new

@@ -127,10 +127,20 @@ # Used in class initialization and after a fork, this method # collects up process information # def collect_process_info process = {} - cmdline = ProcTable.ps(Process.pid).cmdline.split("\0") + cmdline_file = "/proc/#{Process.pid}/cmdline" + + # If there is a /proc filesystem, we read this manually so + # we can split on embedded null bytes. Otherwise (e.g. OSX, Windows) + # use ProcTable. + if File.exist?(cmdline_file) + cmdline = IO.read(cmdline_file).split(?\x00) + else + cmdline = ProcTable.ps(Process.pid).cmdline.split(?\x00) + end + process[:name] = cmdline.shift process[:arguments] = cmdline if RUBY_PLATFORM =~ /darwin/i # Handle OSX bug where env vars show up at the end of process name