sys-proctable 0.7.5-mswin32 → 0.7.6-mswin32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +17 -1
- data/MANIFEST +1 -1
- data/README +38 -29
- data/lib/sys/proctable.rb +3 -7
- data/test/tc_all.rb +15 -26
- data/test/tc_freebsd.rb +0 -19
- data/test/tc_hpux.rb +0 -18
- data/test/tc_kvm_bsd.rb +0 -14
- data/test/tc_linux.rb +2 -18
- data/test/tc_sunos.rb +0 -17
- data/test/tc_top.rb +0 -8
- data/test/tc_windows.rb +2 -8
- metadata +3 -3
data/CHANGES
CHANGED
@@ -1,5 +1,21 @@
|
|
1
|
+
== 0.7.6 - 11-Jul-2007
|
2
|
+
* Fixed the starttime for Linux. Thanks go to Yaroslav Dmitriev for the spot.
|
3
|
+
* Fixed a bug in the MS Windows version within a private method that parsed
|
4
|
+
an MS specific date format. This was caused by a backwards incompatible
|
5
|
+
change in the Time.parse method in Ruby 1.8.6. See ruby-core: 11245 ff.
|
6
|
+
* Fixed the gemspec (I hope). Please let me know if you have problems.
|
7
|
+
* Added a Rakefile. Building, testing and installing should now be handled via
|
8
|
+
Rake tasks. The install.rb file has been removed - that code is now
|
9
|
+
integrated in the Rakefile.
|
10
|
+
* Minor directory layout changes and cleanup (mostly for the extconf.rb file).
|
11
|
+
* Side note - it seems that the code for OS X *does* work, at least on 10.4.10.
|
12
|
+
I can only conclude that previous reports about it failing were related to
|
13
|
+
bugs in OS X or were really just build issues. Apologies (and thanks, again)
|
14
|
+
to David Felstead for the code. However, see the README for more information
|
15
|
+
specific to OS X, as there are shortcomings.
|
16
|
+
|
1
17
|
== 0.7.5 - 23-Nov-2006
|
2
|
-
* Fixed int/long issues for Linux.
|
18
|
+
* Fixed int/long issues for Linux. Thanks go to Matt Lightner for the spot.
|
3
19
|
* Minor documentation fixes and changes to the extconf.rb file.
|
4
20
|
|
5
21
|
== 0.7.4 - 20-Nov-2006
|
data/MANIFEST
CHANGED
data/README
CHANGED
@@ -13,17 +13,11 @@
|
|
13
13
|
* FreeBSD (/proc or kvm)
|
14
14
|
* Solaris
|
15
15
|
* HP-UX
|
16
|
+
* OS X
|
16
17
|
|
17
18
|
= Installation
|
18
|
-
|
19
|
-
|
20
|
-
make
|
21
|
-
cd ..; ruby test/ts_all.rb (optional)
|
22
|
-
make install
|
23
|
-
|
24
|
-
=== MS Windows
|
25
|
-
ruby test/tc_windows.rb (optional)
|
26
|
-
ruby install.rb
|
19
|
+
* rake test (optional)
|
20
|
+
* rake install
|
27
21
|
|
28
22
|
= Synopsis
|
29
23
|
require 'sys/proctable'
|
@@ -53,7 +47,7 @@
|
|
53
47
|
|
54
48
|
= Notes
|
55
49
|
Windows users may pass a host name as a second argument to get process
|
56
|
-
information from a different host.
|
50
|
+
information from a different host. This relies on the WMI service running.
|
57
51
|
|
58
52
|
If you're building C source code, the ts_all.rb file is autogenerated for
|
59
53
|
you.
|
@@ -61,56 +55,71 @@
|
|
61
55
|
= Known Issues
|
62
56
|
=== BSD
|
63
57
|
If you're building on FreeBSD, a standard /proc filesystem read approach is
|
64
|
-
used if mounted.
|
58
|
+
used if mounted. Otherwise, a kvm interface is used. There are more fields
|
65
59
|
available with the kvm interface, but keep in mind that you need to be a
|
66
|
-
member of the kvm group (or root) to use this.
|
67
|
-
|
60
|
+
member of the kvm group (or root) to use this. You can tweak the extconf.rb
|
61
|
+
file manually if you want to force the issue.
|
68
62
|
|
69
|
-
Not all fields are available on FreeBSD 5.x (yet).
|
63
|
+
Not all fields are available on FreeBSD 5.x (yet). OpenBSD and NetBSD are
|
70
64
|
not yet supported.
|
71
65
|
|
72
|
-
Research has indicated that the kvm approach is less favored than a sysctl
|
73
|
-
approach. I will try to add this interface in the 0.8.0 release.
|
74
|
-
|
75
66
|
=== Solaris
|
76
67
|
The cmdline member on solaris is limited to 80 characters unless you (or
|
77
|
-
your program) own the process.
|
68
|
+
your program) own the process. This is a Solaris design flaw/feature.
|
69
|
+
|
70
|
+
=== OS X
|
71
|
+
At the moment you do not get the full command line string. The code required
|
72
|
+
to get this information is obnoxious and I don't have any compelling desire
|
73
|
+
to add it. However, if you're willing to submit a patch I'll accept it.
|
74
|
+
|
75
|
+
You can find a good starting point with the OS X code found in Dan Urist's
|
76
|
+
Proc::ProcessTable module. You can find that module on CPAN. Point your
|
77
|
+
browser at http://search.cpan.org.
|
78
78
|
|
79
79
|
=== Misc
|
80
|
-
If you build your library as a C extension (
|
81
|
-
|
82
|
-
is renamed to 'windows.orig'.
|
83
|
-
it during the 'make install' phase.
|
80
|
+
If you build your library as a C extension (which is what will happen if
|
81
|
+
you run the 'build', 'test', or 'install' Rake tasks), then the windows.rb
|
82
|
+
file under 'lib/sys/' is renamed to 'windows.orig'. This is necessary to
|
83
|
+
prevent mkmf from auto-installing it during the 'make install' phase.
|
84
|
+
|
85
|
+
The 'clean' Rake task will rename it back to 'windows.rb'.
|
84
86
|
|
85
87
|
=== Thread Safety
|
86
88
|
I am not currently using a thread-safe version of readdir(). I am not
|
87
89
|
especially concerned about it either. If you are trying to read information
|
88
90
|
out of /proc from different threads at the same time there is something
|
89
|
-
seriously wrong with your code logic.
|
91
|
+
seriously wrong with your code logic. Using readdir_r() still won't solve
|
90
92
|
all potential thread safety issues anyway.
|
91
93
|
|
92
94
|
= Future Plans
|
93
95
|
I'm considering using a pure Ruby version for Linux.
|
94
96
|
|
97
|
+
Research has indicated that the kvm approach is less favored than a sysctl
|
98
|
+
approach on BSD variants. I will try to add this interface in the 0.8.0
|
99
|
+
release.
|
100
|
+
|
95
101
|
= Acknowledgements
|
96
102
|
This package is largely based on the Perl module Proc::ProcessTable by
|
97
103
|
Dan Urist. Many ideas, as well as large chunks of code, were taken
|
98
|
-
from his work.
|
104
|
+
from his work. So, a big THANK YOU goes out to Dan Urist.
|
99
105
|
|
100
106
|
A big thanks also goes out to Mike Hall who was very helpful with ideas,
|
101
107
|
logic and testing.
|
102
108
|
|
103
109
|
Thanks also go to Sean Chittenden for providing an account on one of his
|
104
|
-
FreeBSD machines.
|
110
|
+
FreeBSD machines. This is how the FreeBSD support was (initially) added.
|
105
111
|
|
106
112
|
Thanks go to James Hranicky for providing a patch that grabs name, eid,
|
107
113
|
euid, gid and guid info in the Linux version, along with some general
|
108
114
|
debugging help.
|
109
115
|
|
116
|
+
Finally I'd like to thank all the folks who have submitted bug reports
|
117
|
+
and/or patches.
|
118
|
+
|
110
119
|
= Help Wanted
|
111
|
-
I do not have access to all platforms.
|
112
|
-
out there, namely
|
113
|
-
like to see ports for.
|
120
|
+
I do not have access to all platforms. There are a few other major platforms
|
121
|
+
out there, namely AIX, OpenBSD, and IRIX, among others, that I would
|
122
|
+
like to see ports for. There are two ways you can help - either submit code
|
114
123
|
for your particular platform or give me an account on your platform so I can
|
115
124
|
develop on it.
|
116
125
|
|
@@ -122,7 +131,7 @@
|
|
122
131
|
Ruby's
|
123
132
|
|
124
133
|
= Copyright
|
125
|
-
(C) 2003-
|
134
|
+
(C) 2003-2007 Daniel J. Berger
|
126
135
|
All Rights Reserved.
|
127
136
|
|
128
137
|
= Author
|
data/lib/sys/proctable.rb
CHANGED
@@ -1,17 +1,15 @@
|
|
1
1
|
require 'win32ole'
|
2
2
|
require 'socket'
|
3
|
-
require 'parsedate'
|
4
3
|
|
5
4
|
module Sys
|
6
5
|
class ProcTableError < StandardError; end
|
7
6
|
class ProcTable
|
8
|
-
VERSION = '0.7.
|
7
|
+
VERSION = '0.7.6'
|
9
8
|
|
10
|
-
########################################################################
|
11
9
|
# The comm field corresponds to the 'name' field. The 'cmdline' field
|
12
10
|
# is the CommandLine attribute on Windows XP or later, or the
|
13
11
|
# 'executable_path' field on Windows 2000 or earlier.
|
14
|
-
|
12
|
+
#
|
15
13
|
@fields = %w/
|
16
14
|
caption
|
17
15
|
cmdline
|
@@ -180,8 +178,7 @@ module Sys
|
|
180
178
|
#######################################################################
|
181
179
|
def self.parse_ms_date(str)
|
182
180
|
return if str.nil?
|
183
|
-
|
184
|
-
return Time.mktime(*parsed)
|
181
|
+
return Time.parse(str.split('.').first)
|
185
182
|
end
|
186
183
|
|
187
184
|
#####################################################################
|
@@ -192,6 +189,5 @@ module Sys
|
|
192
189
|
return nil if str.nil? # Return nil, not 0
|
193
190
|
return str.to_i
|
194
191
|
end
|
195
|
-
|
196
192
|
end
|
197
193
|
end
|
data/test/tc_all.rb
CHANGED
@@ -1,27 +1,9 @@
|
|
1
|
-
|
1
|
+
#######################################################################
|
2
2
|
# tc_all.rb
|
3
3
|
#
|
4
|
-
# Test suite for methods common to all platforms.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
if base == 'test' || base =~ /sys-proctable.*/
|
9
|
-
Dir.chdir '..' if base == 'test'
|
10
|
-
|
11
|
-
if RUBY_PLATFORM.match('mswin')
|
12
|
-
File.rename('lib/sys/windows.rb', 'lib/sys/proctable.rb') rescue nil
|
13
|
-
else
|
14
|
-
require 'fileutils'
|
15
|
-
require 'rbconfig'
|
16
|
-
file = 'ext/proctable.' + Config::CONFIG['DLEXT']
|
17
|
-
Dir.mkdir('sys') unless File.exists?('sys')
|
18
|
-
FileUtils.cp(file, 'sys')
|
19
|
-
end
|
20
|
-
|
21
|
-
$LOAD_PATH.unshift(Dir.pwd)
|
22
|
-
$LOAD_PATH.unshift(Dir.pwd + '/lib')
|
23
|
-
end
|
24
|
-
|
4
|
+
# Test suite for methods common to all platforms. Generally speaking
|
5
|
+
# you should run this test case using the 'rake test' task.
|
6
|
+
#######################################################################
|
25
7
|
require 'socket'
|
26
8
|
require 'test/unit'
|
27
9
|
require 'sys/proctable'
|
@@ -30,10 +12,11 @@ include Sys
|
|
30
12
|
class TC_ProcTable_All < Test::Unit::TestCase
|
31
13
|
def setup
|
32
14
|
@host = Socket.gethostname
|
15
|
+
@pid = RUBY_PLATFORM.match('mswin') ? 0 : 1
|
33
16
|
end
|
34
17
|
|
35
18
|
def test_version
|
36
|
-
assert_equal('0.7.
|
19
|
+
assert_equal('0.7.6', ProcTable::VERSION)
|
37
20
|
end
|
38
21
|
|
39
22
|
def test_fields
|
@@ -52,19 +35,25 @@ class TC_ProcTable_All < Test::Unit::TestCase
|
|
52
35
|
def test_ps_with_args
|
53
36
|
assert_nothing_raised{ ProcTable.ps(0) }
|
54
37
|
assert_nothing_raised{ ProcTable.ps(nil) }
|
55
|
-
assert_nothing_raised{ ProcTable.ps(0, @host) }
|
56
38
|
assert_raises(TypeError){ ProcTable.ps('vim') }
|
57
|
-
|
39
|
+
|
40
|
+
if RUBY_PLATFORM.match('mswin')
|
41
|
+
assert_nothing_raised{ ProcTable.ps(0, @host) }
|
42
|
+
assert_raises(ArgumentError){ ProcTable.ps(0, @host, 1) }
|
43
|
+
else
|
44
|
+
assert_raises(ArgumentError){ ProcTable.ps(0, @host) }
|
45
|
+
end
|
58
46
|
end
|
59
47
|
|
60
48
|
def test_ps_return_values
|
61
49
|
assert_kind_of(Array, ProcTable.ps)
|
62
|
-
assert_kind_of(Struct::ProcTableStruct, ProcTable.ps(
|
50
|
+
assert_kind_of(Struct::ProcTableStruct, ProcTable.ps(@pid))
|
63
51
|
assert_equal(nil, ProcTable.ps(999999999))
|
64
52
|
assert_equal(nil, ProcTable.ps{})
|
65
53
|
end
|
66
54
|
|
67
55
|
def teardown
|
68
56
|
@host = nil
|
57
|
+
@pid = nil
|
69
58
|
end
|
70
59
|
end
|
data/test/tc_freebsd.rb
CHANGED
@@ -3,27 +3,12 @@
|
|
3
3
|
#
|
4
4
|
# Test suite for sys-proctable for FreeBSD.
|
5
5
|
############################################
|
6
|
-
base = File.basename(Dir.pwd)
|
7
|
-
|
8
|
-
if base == 'test' || base =~ /sys-proctable.*/
|
9
|
-
require 'fileutils'
|
10
|
-
require 'rbconfig'
|
11
|
-
|
12
|
-
Dir.chdir '..' if base == 'test'
|
13
|
-
file = 'ext/proctable.' + Config::CONFIG['DLEXT']
|
14
|
-
Dir.mkdir('sys') unless File.exists?('sys')
|
15
|
-
FileUtils.cp(file, 'sys')
|
16
|
-
|
17
|
-
$LOAD_PATH.unshift(Dir.pwd)
|
18
|
-
end
|
19
|
-
|
20
6
|
require "sys/proctable"
|
21
7
|
require "test/unit"
|
22
8
|
require "test/tc_all"
|
23
9
|
include Sys
|
24
10
|
|
25
11
|
class TC_ProcTable_FreeBSD < Test::Unit::TestCase
|
26
|
-
|
27
12
|
def setup
|
28
13
|
@fields = %w/
|
29
14
|
comm pid ppid pgid sid tdev_maj tdev_min flags start
|
@@ -57,8 +42,4 @@ class TC_ProcTable_FreeBSD < Test::Unit::TestCase
|
|
57
42
|
@fields = nil
|
58
43
|
@pt = nil
|
59
44
|
end
|
60
|
-
|
61
|
-
alias :set_up :setup
|
62
|
-
alias :tear_down :teardown
|
63
|
-
|
64
45
|
end
|
data/test/tc_hpux.rb
CHANGED
@@ -3,27 +3,12 @@
|
|
3
3
|
#
|
4
4
|
# Test case for sys-proctable for HP-UX.
|
5
5
|
##################################################
|
6
|
-
base = File.basename(Dir.pwd)
|
7
|
-
|
8
|
-
if base == 'test' || base =~ /sys-proctable.*/
|
9
|
-
require 'fileutils'
|
10
|
-
require 'rbconfig'
|
11
|
-
|
12
|
-
Dir.chdir('..') if base == 'test'
|
13
|
-
file = 'ext/proctable.' + Config::CONFIG['DLEXT']
|
14
|
-
Dir.mkdir('sys') unless File.exists?('sys')
|
15
|
-
FileUtils.cp(file, 'sys')
|
16
|
-
|
17
|
-
$LOAD_PATH.unshift(Dir.pwd)
|
18
|
-
end
|
19
|
-
|
20
6
|
require "sys/proctable"
|
21
7
|
require "test/unit"
|
22
8
|
require "test/tc_all"
|
23
9
|
include Sys
|
24
10
|
|
25
11
|
class TC_ProcTable_HPUX < Test::Unit::TestCase
|
26
|
-
|
27
12
|
def setup
|
28
13
|
@fields = %w/
|
29
14
|
comm uid pid ppid dsize tsize ssize nice ttydev pgrp pri addr
|
@@ -61,7 +46,4 @@ class TC_ProcTable_HPUX < Test::Unit::TestCase
|
|
61
46
|
@fields = nil
|
62
47
|
@pt = nil
|
63
48
|
end
|
64
|
-
|
65
|
-
alias :set_up :setup
|
66
|
-
alias :tear_down :teardown
|
67
49
|
end
|
data/test/tc_kvm_bsd.rb
CHANGED
@@ -3,20 +3,6 @@
|
|
3
3
|
#
|
4
4
|
# Test suite for the BSD specific version of the kvm interface.
|
5
5
|
################################################################
|
6
|
-
base = File.basename(Dir.pwd)
|
7
|
-
|
8
|
-
if base == 'test' || base =~ /sys-proctable.*/
|
9
|
-
require 'fileutils'
|
10
|
-
require 'rbconfig'
|
11
|
-
|
12
|
-
Dir.chdir '..' if base == 'test'
|
13
|
-
file = 'ext/proctable.' + Config::CONFIG['DLEXT']
|
14
|
-
Dir.mkdir('sys') unless File.exists?('sys')
|
15
|
-
FileUtils.cp(file, 'sys')
|
16
|
-
|
17
|
-
$LOAD_PATH.unshift(Dir.pwd)
|
18
|
-
end
|
19
|
-
|
20
6
|
require "test/unit"
|
21
7
|
require "sys/proctable"
|
22
8
|
include Sys
|
data/test/tc_linux.rb
CHANGED
@@ -3,20 +3,8 @@
|
|
3
3
|
#
|
4
4
|
# Test suite for sys-proctable for Linux.
|
5
5
|
##########################################
|
6
|
-
|
7
|
-
|
8
|
-
if base == 'test' || base =~ /sys-proctable.*/
|
9
|
-
require 'fileutils'
|
10
|
-
require 'rbconfig'
|
11
|
-
|
12
|
-
Dir.chdir('..') if base == 'test'
|
13
|
-
file = 'ext/proctable.' + Config::CONFIG['DLEXT']
|
14
|
-
Dir.mkdir('sys') unless File.exists?('sys')
|
15
|
-
FileUtils.cp(file, 'sys')
|
16
|
-
|
17
|
-
$LOAD_PATH.unshift(Dir.pwd)
|
18
|
-
end
|
19
|
-
|
6
|
+
require "sys/proctable"
|
7
|
+
require "test/unit"
|
20
8
|
require "test/tc_all"
|
21
9
|
|
22
10
|
class TC_ProcTable_Linux < Test::Unit::TestCase
|
@@ -54,8 +42,4 @@ class TC_ProcTable_Linux < Test::Unit::TestCase
|
|
54
42
|
def teardown
|
55
43
|
@pt = nil
|
56
44
|
end
|
57
|
-
|
58
|
-
alias :set_up :setup
|
59
|
-
alias :tear_down :teardown
|
60
|
-
|
61
45
|
end
|
data/test/tc_sunos.rb
CHANGED
@@ -3,20 +3,6 @@
|
|
3
3
|
#
|
4
4
|
# Test suite for sys-proctable for SunOS/Solaris.
|
5
5
|
##################################################
|
6
|
-
base = File.basename(Dir.pwd)
|
7
|
-
|
8
|
-
if base == 'test' || base =~ /sys-proctable.*/
|
9
|
-
require 'fileutils'
|
10
|
-
require 'rbconfig'
|
11
|
-
|
12
|
-
Dir.chdir '..' if base == 'test'
|
13
|
-
file = 'ext/proctable.' + Config::CONFIG['DLEXT']
|
14
|
-
Dir.mkdir('sys') unless File.exists?('sys')
|
15
|
-
FileUtils.cp(file, 'sys')
|
16
|
-
|
17
|
-
$LOAD_PATH.unshift(Dir.pwd)
|
18
|
-
end
|
19
|
-
|
20
6
|
require "sys/proctable"
|
21
7
|
require "test/unit"
|
22
8
|
require "test/tc_all"
|
@@ -63,7 +49,4 @@ class TC_ProcTable_SunOS < Test::Unit::TestCase
|
|
63
49
|
@pt = nil
|
64
50
|
@fields = nil
|
65
51
|
end
|
66
|
-
|
67
|
-
alias :set_up :setup
|
68
|
-
alias :tear_down :teardown
|
69
52
|
end
|
data/test/tc_top.rb
CHANGED
@@ -3,14 +3,6 @@
|
|
3
3
|
#
|
4
4
|
# Test suite for the sys-top package that is included with this distribution.
|
5
5
|
##############################################################################
|
6
|
-
base = File.basename(Dir.pwd)
|
7
|
-
|
8
|
-
if base == 'test' || base =~ /sys-proctable.*/
|
9
|
-
Dir.chdir('..') if base == 'test'
|
10
|
-
$LOAD_PATH.unshift(Dir.pwd)
|
11
|
-
$LOAD_PATH.unshift(Dir.pwd + '/lib')
|
12
|
-
end
|
13
|
-
|
14
6
|
require 'test/unit'
|
15
7
|
require 'sys/top'
|
16
8
|
include Sys
|
data/test/tc_windows.rb
CHANGED
@@ -3,14 +3,8 @@
|
|
3
3
|
#
|
4
4
|
# Test suite for sys-proctable for MS Windows
|
5
5
|
##################################################
|
6
|
-
|
7
|
-
|
8
|
-
if base == 'test' || base =~ /sys-proctable.*/
|
9
|
-
Dir.chdir('..') if base == 'test'
|
10
|
-
File.rename("lib/sys/windows.rb", "lib/sys/proctable.rb") rescue nil
|
11
|
-
$LOAD_PATH.unshift(Dir.pwd + '/lib')
|
12
|
-
end
|
13
|
-
|
6
|
+
require 'sys/proctable'
|
7
|
+
require 'test/unit'
|
14
8
|
require 'test/tc_all'
|
15
9
|
|
16
10
|
class TC_ProcTable_MSWindows < Test::Unit::TestCase
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.2
|
3
3
|
specification_version: 1
|
4
4
|
name: sys-proctable
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.7.
|
7
|
-
date:
|
6
|
+
version: 0.7.6
|
7
|
+
date: 2007-07-11 00:00:00 -06:00
|
8
8
|
summary: An interface for providing process table information
|
9
9
|
require_paths:
|
10
10
|
- lib
|