sys-proctable 0.8.0-x86-linux → 0.8.1-x86-linux

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,13 @@
1
+ == 0.8.1 - 6-Apr-2009
2
+ * The Linux and Solaris libraries now handle the possibility of a process
3
+ terminating in the middle of a read more gracefully. If that happens, they
4
+ merely skip to the next record, i.e. it's all or nothing. Thanks go to
5
+ Heejong Lee for the spot and patch.
6
+ * Fixed a bug in the Linux version where embedded nulls were not being
7
+ stripped out of the cmdline data.
8
+ * Added the comm alias back to the Solaris version. Thanks go to Jun Young Kim
9
+ for the spot.
10
+
1
11
  == 0.8.0 - 26-Jan-2009
2
12
  * The Linux and Solaris versions of this library are now pure Ruby. Be warned,
3
13
  however, that only Solaris 8 and later are now supported. This may change
@@ -8,7 +8,7 @@ module Sys
8
8
  private_class_method :new
9
9
 
10
10
  # The version of the sys-proctable library
11
- VERSION = '0.8.0'
11
+ VERSION = '0.8.1'
12
12
 
13
13
  private
14
14
 
@@ -87,6 +87,12 @@ module Sys
87
87
  # # Print process table information for only pid 1001
88
88
  # p ProcTable.ps(1001)
89
89
  #
90
+ #--
91
+ # It's possible that a process could terminate while gathering
92
+ # information for that process. When that happens, this library
93
+ # will simply skip to the next record. In short, this library will
94
+ # either return all information for a process, or none at all.
95
+ #
90
96
  def self.ps(pid=nil)
91
97
  array = block_given? ? nil : []
92
98
  struct = nil
@@ -99,8 +105,13 @@ module Sys
99
105
 
100
106
  struct = ProcTableStruct.new
101
107
 
102
- # Get /proc/<pid>/cmdline information
103
- struct.cmdline = IO.read("/proc/#{file}/cmdline")
108
+ # Get /proc/<pid>/cmdline information. Strip out embedded nulls.
109
+ begin
110
+ data = IO.read("/proc/#{file}/cmdline").tr("\000", ' ').strip
111
+ struct.cmdline = data
112
+ rescue
113
+ next # Process terminated, on to the next process
114
+ end
104
115
 
105
116
  # Get /proc/<pid>/cwd information
106
117
  struct.cwd = File.readlink("/proc/#{file}/cwd") rescue nil
@@ -139,7 +150,7 @@ module Sys
139
150
  struct.root = File.readlink("/proc/#{file}/root") rescue nil
140
151
 
141
152
  # Get /proc/<pid>/stat information
142
- stat = IO.read("/proc/#{file}/stat")
153
+ stat = IO.read("/proc/#{file}/stat") rescue next
143
154
 
144
155
  # Deal with spaces in comm name. Courtesy of Ara Howard.
145
156
  re = %r/\([^\)]+\)/
@@ -23,7 +23,7 @@ class TC_ProcTable_All < Test::Unit::TestCase
23
23
  end
24
24
 
25
25
  def test_version
26
- assert_equal('0.8.0', ProcTable::VERSION)
26
+ assert_equal('0.8.1', ProcTable::VERSION)
27
27
  end
28
28
 
29
29
  def test_fields
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sys-proctable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: x86-linux
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-26 00:00:00 -07:00
12
+ date: 2009-01-29 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency