sys-proctable 0.8.2-x86-solaris-2.10
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +289 -0
- data/MANIFEST +30 -0
- data/README +126 -0
- data/Rakefile +167 -0
- data/benchmarks/bench_ps.rb +21 -0
- data/doc/top.txt +47 -0
- data/examples/example_ps.rb +20 -0
- data/lib/sunos/sys/proctable.rb +462 -0
- data/lib/sys/top.rb +37 -0
- data/sys-proctable.gemspec +40 -0
- data/test/test_sys_proctable_all.rb +85 -0
- data/test/test_sys_proctable_sunos.rb +308 -0
- metadata +79 -0
data/CHANGES
ADDED
@@ -0,0 +1,289 @@
|
|
1
|
+
== 0.9.0 - 14-Oct-2009
|
2
|
+
* Changed the license to Artistic 2.0.
|
3
|
+
* Fixed a bug in the OS X code where a segfault would occur when an attempt
|
4
|
+
was made to gather resource usage information on zombie processes. From
|
5
|
+
now on that information is always set to nil for zombie processes. Thanks
|
6
|
+
go to Tom Lianza for the spot and Philip Kromer for investigating the
|
7
|
+
root cause of the failure.
|
8
|
+
* Removed the FreeBSD code that read out of /proc. It was a pain from a
|
9
|
+
maintenance point of view, and most FreeBSD installs do not mount /proc
|
10
|
+
by default. The FreeBSD platform now uses the same code that the other
|
11
|
+
BSD platforms use.
|
12
|
+
* Fixed a bug in the BSD code where the ProcTable::Error class had the
|
13
|
+
wrong parent class.
|
14
|
+
* Some major gemspec updates, including an updated license. The platform
|
15
|
+
handling logic is now in the Rakefile in the 'gem' task.
|
16
|
+
* Updated the README file to include an additional acknowledgement, a
|
17
|
+
license change and some minor formatting changes.
|
18
|
+
* The test-unit library was changed from a runtime to a development dependency.
|
19
|
+
|
20
|
+
== 0.8.1 - 6-Apr-2009
|
21
|
+
* The Linux and Solaris libraries now handle the possibility of a process
|
22
|
+
terminating in the middle of a read more gracefully. If that happens, they
|
23
|
+
merely skip to the next record, i.e. it's all or nothing. Thanks go to
|
24
|
+
Heejong Lee for the spot and patch.
|
25
|
+
* Fixed a bug in the Linux version where embedded nulls were not being
|
26
|
+
stripped out of the cmdline data.
|
27
|
+
* Added the comm alias back to the Solaris version. Thanks go to Jun Young Kim
|
28
|
+
for the spot.
|
29
|
+
|
30
|
+
== 0.8.0 - 26-Jan-2009
|
31
|
+
* The Linux and Solaris versions of this library are now pure Ruby. Be warned,
|
32
|
+
however, that only Solaris 8 and later are now supported. This may change
|
33
|
+
in a future release if there's demand to support 2.6 and 2.7.
|
34
|
+
* Some Struct::ProcTableStruct members have changed. As a general rule they
|
35
|
+
now more closely match the C struct member name. See individual platforms
|
36
|
+
for more details.
|
37
|
+
* Bug fix for the cmd_args struct member on Solaris.
|
38
|
+
* Bug fixes for OS X. Added a VERSION constant, fixed struct name, and changed
|
39
|
+
pct_cpu to pctcpu.
|
40
|
+
* The .new method is now explicitly illegal.
|
41
|
+
* The Struct::ProcTableStruct instances are now frozen. This is read-only data.
|
42
|
+
* Added the peak_page_file_usage and status members on MS Windows. The status
|
43
|
+
member is always nil, but was added for completeness.
|
44
|
+
* Fixed the quota_peak_paged_pool_usage member on MS Windows.
|
45
|
+
* ProcTableError is now ProcTable::Error.
|
46
|
+
* Minor test case fix for kvm/bsd based versions.
|
47
|
+
* Added the 'time' library as a require for Windows (to parse MS date/time
|
48
|
+
format strings).
|
49
|
+
* The kvm (bsd.c) implementation now works for FreeBSD 7.
|
50
|
+
* Added many more tests.
|
51
|
+
* Added some benchmarking code in the 'benchmarks' directory.
|
52
|
+
* Added a 'bench' Rake task.
|
53
|
+
* Renamed the test_ps.rb file to example_ps.rb in order to avoid any possible
|
54
|
+
confusion with actual test files.
|
55
|
+
* Added an 'example' rake task to run the example file.
|
56
|
+
|
57
|
+
== 0.7.6 - 11-Jul-2007
|
58
|
+
* Fixed the starttime for Linux. Thanks go to Yaroslav Dmitriev for the spot.
|
59
|
+
* Fixed a bug in the MS Windows version within a private method that parsed
|
60
|
+
an MS specific date format. This was caused by a backwards incompatible
|
61
|
+
change in the Time.parse method in Ruby 1.8.6. See ruby-core: 11245 ff.
|
62
|
+
* Fixed the gemspec (I hope). Please let me know if you have problems.
|
63
|
+
* Added a Rakefile. Building, testing and installing should now be handled via
|
64
|
+
Rake tasks. The install.rb file has been removed - that code is now
|
65
|
+
integrated in the Rakefile.
|
66
|
+
* Minor directory layout changes and cleanup (mostly for the extconf.rb file).
|
67
|
+
* Side note - it seems that the code for OS X *does* work, at least on 10.4.10.
|
68
|
+
I can only conclude that previous reports about it failing were related to
|
69
|
+
bugs in OS X or were really just build issues. Apologies (and thanks, again)
|
70
|
+
to David Felstead for the code. However, see the README for more information
|
71
|
+
specific to OS X, as there are shortcomings.
|
72
|
+
|
73
|
+
== 0.7.5 - 23-Nov-2006
|
74
|
+
* Fixed int/long issues for Linux. Thanks go to Matt Lightner for the spot.
|
75
|
+
* Minor documentation fixes and changes to the extconf.rb file.
|
76
|
+
|
77
|
+
== 0.7.4 - 20-Nov-2006
|
78
|
+
* Added a patch that deals with the large file compilation issue on Solaris.
|
79
|
+
You no longer need to build Ruby with --disable-largefile, or build a
|
80
|
+
64 bit Ruby, in order for this package to work. Thanks go to Steven Jenkins
|
81
|
+
for the information that led to the patch.
|
82
|
+
* Added inline rdoc to the source code.
|
83
|
+
* Added a gemspec.
|
84
|
+
* Fixed some potential 64 bit issues (struct declarations).
|
85
|
+
* Added preliminary support for Darwin (OS X). The code was provided by
|
86
|
+
David Felstead, but does not appear to compile successfully. Help wanted.
|
87
|
+
|
88
|
+
== 0.7.3 - 27-Oct-2005
|
89
|
+
* Fix for 1.8.3 and later (rb_pid_t). This should have only affected
|
90
|
+
Solaris.
|
91
|
+
|
92
|
+
== 0.7.2 - 15-May-2005
|
93
|
+
* Bug fix for the FreeBSD version that reads from /proc.
|
94
|
+
* Eliminated the test bug on Linux (inexplicably caused by File.copy). The
|
95
|
+
test suite should now run without segfaulting.
|
96
|
+
* Include bsd.c in tarball (oops).
|
97
|
+
* Minor test updates for FreeBSD.
|
98
|
+
* The 'pct_cpu' member for the BSD/kvm version has been changed to 'pctcpu'
|
99
|
+
for consistency with other platforms.
|
100
|
+
|
101
|
+
== 0.7.1 - 8-May-2005
|
102
|
+
* Bug fixed for the cmdline info on Linux. Thanks go to Arash Abedinzadeh
|
103
|
+
for the spot.
|
104
|
+
* Added an example program.
|
105
|
+
* Minor setup fix for Win32 in tc_all.rb.
|
106
|
+
|
107
|
+
== 0.7.0 - 25-Apr-2005
|
108
|
+
* Scrapped the C implementation for Windows in favor of an OLE + WMI pure Ruby
|
109
|
+
approach. See documentation for details.
|
110
|
+
* Added an optional lkvm implementation for BSD users. This is automatically
|
111
|
+
used if the /proc filesystem isn't found.
|
112
|
+
* Added prusage info for the Solaris version.
|
113
|
+
* Added name, eid, euid, gid and guid information for Linux. Thanks go to
|
114
|
+
James Hranicky for the patch.
|
115
|
+
* Fixed some potential bugs in the Linux version. Thanks go to James
|
116
|
+
Hranicky for the spot.
|
117
|
+
* Added the 'sys/top' package.
|
118
|
+
* ProcTable.fields no longer supports a block form.
|
119
|
+
* The BTIME (boot time) information has been removed from the Linux version.
|
120
|
+
If you want that information, use sys-uptime instead.
|
121
|
+
* The .html and .rd files have been removed. You can generate html on your
|
122
|
+
own with rdoc if you like.
|
123
|
+
* Some code cleanup on the C side of the house.
|
124
|
+
* Most documents made rdoc friendly.
|
125
|
+
* Renamed 'install_pure_ruby.rb' to just 'install.rb'.
|
126
|
+
* Removed the 'INSTALL' file. Installation instructions are in the README.
|
127
|
+
* Some test suite cleanup and reorganization.
|
128
|
+
* Moved project to RubyForge.
|
129
|
+
|
130
|
+
== 0.6.4 - 31-Mar-2004
|
131
|
+
* Fixed a bug in the pure Ruby version for Win32. Thanks go to Mark Hudson
|
132
|
+
for the spot.
|
133
|
+
* Fixed a bug in the C implementation for Win32 where the cmdline and path
|
134
|
+
values were sometimes wrong for running processes. Thanks go to Park Heesob
|
135
|
+
for the fix.
|
136
|
+
* Updated the VERSION constant and removed the VERSION class method in the
|
137
|
+
pure Ruby version for Win32.
|
138
|
+
* Updated install_pure_ruby.rb and test.rb scripts.
|
139
|
+
* Updated warranty information.
|
140
|
+
* The extconf.rb script has been revamped. See the INSTALL and README files
|
141
|
+
for important changes since the last release.
|
142
|
+
* The start ProcInfo struct member on Solaris, HP-UX and FreeBSD is now a
|
143
|
+
Time object, not a Fixnum/Bignum.
|
144
|
+
* Modified linux.c yet again to make gcc happy when it comes to multi-line
|
145
|
+
string literals.
|
146
|
+
* Minor change to way process state is handled on HP-UX.
|
147
|
+
* Documentation additions and updates, including warranty information.
|
148
|
+
|
149
|
+
== 0.6.3 - 24-Feb-2004
|
150
|
+
* Fixed a bug in the Solaris version where the cmd_args array did not
|
151
|
+
necessarily contain data on 2.7 and later. The current patch still
|
152
|
+
does not quite fix the problem for 2.6 and earlier but can be easily
|
153
|
+
derived manually by parsing the cmdline string.
|
154
|
+
|
155
|
+
== 0.6.2 - 20-Jan-2004
|
156
|
+
* Fixed a small memory leak in the solaris version.
|
157
|
+
|
158
|
+
== 0.6.1 - 31-Dec-2003
|
159
|
+
* Fixed a minor bug in the cmdline field on Linux where a blank character
|
160
|
+
was being appended to the end of the field.
|
161
|
+
* Fixed a minor annoyance where the windows.rb file was being copied into
|
162
|
+
the Ruby lib directory on install.
|
163
|
+
* Added a test_memleak.rb file. Currently only supported on Linux and
|
164
|
+
only does a file descriptor count check. I plan to expand this to
|
165
|
+
other platforms in the future.
|
166
|
+
* Minor test suite changes
|
167
|
+
* MANIFEST correction and update.
|
168
|
+
|
169
|
+
== 0.6.0 - 22-Oct-2003
|
170
|
+
* Significant API change (and thus, a version jump) - only a
|
171
|
+
single argument is now accepted to the ps() method, and only a PID
|
172
|
+
(Fixnum) is regarded as a valid argument.
|
173
|
+
* Calling ps() with a pid returns a single ProcTable struct (or nil
|
174
|
+
if the pid is not found), instead of a one element array.
|
175
|
+
* Argument to ps() now works properly on HP-UX and Win32.
|
176
|
+
* Removed the '#include <sys/types32.h>' in sunos.h. It wasn't needed
|
177
|
+
and you're not supposed to include it directly.
|
178
|
+
* Fixed 2.6 compatibility issue with regards to cmdline on Solaris.
|
179
|
+
* Removed the ProcStatException completely on Linux. There was no reason
|
180
|
+
to fail on a directory read for /proc/xxx/stat. If the read fails
|
181
|
+
(meaning the process died in the middle of collecting info for it), it
|
182
|
+
is simply ignored.
|
183
|
+
* The ttynum bug on HPUX has been fixed. In addition, the return value for
|
184
|
+
this field is now a string rather than an int and the field name has
|
185
|
+
been changed to "ttydev".
|
186
|
+
* The ttynum field has been changed to ttydev on Solaris and HPUX. On
|
187
|
+
Solaris, the ttydev is now reported as -1 if there is no associated tty.
|
188
|
+
In a future release, Solaris and the other *nix platforms will be changed
|
189
|
+
so that ttydev is always a device name (i.e String).
|
190
|
+
* Added plain text documentation for all platforms.
|
191
|
+
* Some test suite cleanup.
|
192
|
+
* Changed .rd2 extension to just '.rd'.
|
193
|
+
|
194
|
+
== 0.5.2 - 18-Jul-2003
|
195
|
+
* Modified cmdline to extend past the traditional 80 character limit on
|
196
|
+
Solaris, where possible (Solaris 2.6+ only).
|
197
|
+
* Added the cmdline_args and num_args fields on Solaris, which returns
|
198
|
+
an array of cmdline arguments and the number of cmdline arguments,
|
199
|
+
respectively.
|
200
|
+
* Minor modification to fields() method, in addition to warning cleanup
|
201
|
+
for Solaris.
|
202
|
+
* Changed "defunct" state string to "zombie" for Solaris.
|
203
|
+
* Should cleanly compile with -Wall -W now (gcc) on Solaris.
|
204
|
+
* Added solaris.txt to doc directory.
|
205
|
+
* MANIFEST corrections.
|
206
|
+
|
207
|
+
== 0.5.1 - 16-Jul-2003
|
208
|
+
* Fixed a nasty file descriptor bug in the Linux code, where file descriptors
|
209
|
+
were continuously being used up.
|
210
|
+
* Added the BTIME (boot time) constant for Linux.
|
211
|
+
* Fixed up the test/test.rb file a bit.
|
212
|
+
* Added BTIME tests to tc_linux.rb.
|
213
|
+
|
214
|
+
== 0.5.0 - 11-Jul-200
|
215
|
+
* Added HP-UX support!
|
216
|
+
* Note that passing PID's or strings as arguments to ps() is not supported
|
217
|
+
in the HP-UX version. This functionality will be stripped out of the
|
218
|
+
other versions in a future release. See the README file for more details.
|
219
|
+
* Removed the VERSION() class method. Use the constant instead.
|
220
|
+
* Separated the rd docs from their respective source files. Now in the doc
|
221
|
+
directory.
|
222
|
+
* Got rid of the interactive html generation in extconf.rb.
|
223
|
+
* Changed License to Artistic.
|
224
|
+
|
225
|
+
== 0.4.3 - 30-May-2003
|
226
|
+
* Added a version.h file to store the version number. Modified all of the
|
227
|
+
C source files to use that instead of hard coding the version everywhere.
|
228
|
+
* Added a generic test.rb script for those without TestUnit installed, or
|
229
|
+
just futzing in general. Modified the extconf.rb script to copy this
|
230
|
+
instead of writing an inline HERE document.
|
231
|
+
* Modified extconf.rb so that it builds with mingw or cygwin. Thanks go to
|
232
|
+
Peter Fischer for the spot and patch.
|
233
|
+
* Modified test suite to work with TestUnit 0.1.6 or 0.1.8.
|
234
|
+
|
235
|
+
== 0.4.2 - 14-Apr-2003
|
236
|
+
* Added pure Ruby version for Win32 - thanks Park Heesob.
|
237
|
+
* Modified extconf.rb file to handle pure Ruby versions.
|
238
|
+
* Added install_pure_ruby.rb file, an alternate installation
|
239
|
+
script for pure Ruby versions.
|
240
|
+
|
241
|
+
== 0.4.1 - 31-Mar-2003
|
242
|
+
* Added support for Solaris 2.5.x.
|
243
|
+
* All exceptions are now a direct subclass of StandardError.
|
244
|
+
* Value returned for wchan now more meaningful (2.5.x only for now).
|
245
|
+
* Fixed the start, utime and ctime for FreeBSD.
|
246
|
+
* Minor fix to FreeBSD test suite.
|
247
|
+
* Some changes to extconf.rb.
|
248
|
+
* Minor doc changes.
|
249
|
+
* Added License and Copyright info.
|
250
|
+
|
251
|
+
== 0.4.0 - 10-Mar-2003
|
252
|
+
* Added MS Windows support (non-cygwin).
|
253
|
+
* Added environment information for Linux version.
|
254
|
+
* Added real exceptions (type depends on platform).
|
255
|
+
* Added a test suite (for those with testunit installed).
|
256
|
+
* Removed the sys-uname requirement.
|
257
|
+
* Heavily modified the extconf.rb script.
|
258
|
+
* Changed "Changelog" to "CHANGES" and "Manifest" to "MANIFEST".
|
259
|
+
* Added a VERSION constant and class method.
|
260
|
+
* Minor internal directory layout change (put 'os' under 'lib').
|
261
|
+
* Changed package name to lower case.
|
262
|
+
* Doc changes, including license information.
|
263
|
+
|
264
|
+
== 0.3.1 - 16-Aug-2002
|
265
|
+
* Added a "comm" field to the sunos version. I am going to try to make this a
|
266
|
+
common field for all platforms to help reduce RUBY_PLATFORM checking.
|
267
|
+
* Fixed the release date for 0.3.0 (was accidentally marked *July*).
|
268
|
+
* Added an INSTALL file.
|
269
|
+
* Minor documentation change to the sunos.c source file.
|
270
|
+
|
271
|
+
== 0.3.0 - 11-Aug-2002
|
272
|
+
* Added FreeBSD support!
|
273
|
+
* Struct name changed to just "ProcTableStruct" to be compliant with future
|
274
|
+
versions of Ruby.
|
275
|
+
* The ps() function now returns an array of ProcTableStruct's in lvalue context.
|
276
|
+
* Fixed the ability to search by process name in Linux.
|
277
|
+
* Modified Linux "comm" field to strip parenthesis.
|
278
|
+
* Some doc changes/additions.
|
279
|
+
* Added Sean Chittenden to the "Acknowledgements" section. Sean provided me
|
280
|
+
with access to a FreeBSD box, which is how I was able to provide FreeBSD
|
281
|
+
support. Thanks Sean!
|
282
|
+
|
283
|
+
== 0.2.0 - 19-Jul-2002
|
284
|
+
* Added the ability to search by process name.
|
285
|
+
* test.rb modified to be cross-platform.
|
286
|
+
* Solaris - fixed bug with fname (was accidentally called "name").
|
287
|
+
|
288
|
+
== 0.1.0 - 2-Jul-2002
|
289
|
+
- Initial release.
|
data/MANIFEST
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
* CHANGES
|
2
|
+
* MANIFEST
|
3
|
+
* Rakefile
|
4
|
+
* README
|
5
|
+
* sys-proctable.gemspec
|
6
|
+
* doc/bsd.txt
|
7
|
+
* doc/hpux.txt
|
8
|
+
* doc/linux.txt
|
9
|
+
* doc/solaris.txt
|
10
|
+
* doc/top.txt
|
11
|
+
* doc/windows.txt
|
12
|
+
* example/example_ps.rb
|
13
|
+
* ext/bsd/extconf.rb
|
14
|
+
* ext/bsd/sys/proctable.c
|
15
|
+
* ext/darwin/extconf.rb
|
16
|
+
* ext/darwin/sys/proctable.c
|
17
|
+
* ext/hpux/extconf.rb
|
18
|
+
* ext/hpux/sys/proctable.c
|
19
|
+
* lib/sys/top.rb
|
20
|
+
* lib/linux/sys/proctable.rb
|
21
|
+
* lib/sunos/sys/proctable.rb
|
22
|
+
* lib/windows/sys/proctable.rb
|
23
|
+
* test/test_sys_proctable_all.rb
|
24
|
+
* test/test_sys_proctable_darwin.rb
|
25
|
+
* test/test_sys_proctable_hpux.rb
|
26
|
+
* test/test_sys_proctable_bsd.rb
|
27
|
+
* test/test_sys_proctable_linux.rb
|
28
|
+
* test/test_sys_proctable_sunos.rb
|
29
|
+
* test/test_sys_proctable_windows.rb
|
30
|
+
* test/test_sys_top.rb
|
data/README
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
== Description
|
2
|
+
A Ruby interface for gathering process information.
|
3
|
+
|
4
|
+
== Prerequisites
|
5
|
+
* Ruby 1.8.2 or later
|
6
|
+
* Test::Unit 2.x (development only)
|
7
|
+
|
8
|
+
== Supported Platforms
|
9
|
+
* Windows NT family (NT, 2000, XP, etc)
|
10
|
+
* Linux 2.6+
|
11
|
+
* BSD (various flavors)
|
12
|
+
* Solaris 8+
|
13
|
+
* HP-UX 10+
|
14
|
+
* OS X 10.4+
|
15
|
+
|
16
|
+
== Installation
|
17
|
+
=== Rubygems
|
18
|
+
gem install sys-proctable
|
19
|
+
|
20
|
+
You may need to specify a platform in some cases. For example:
|
21
|
+
|
22
|
+
gem install sys-proctable --platform mswin32 # Windows
|
23
|
+
gem install sys-proctable --platform sunos # Solaris
|
24
|
+
gem install sys-proctalbe --platform linux # Linux
|
25
|
+
|
26
|
+
=== Standard
|
27
|
+
rake install
|
28
|
+
|
29
|
+
= Synopsis
|
30
|
+
require 'sys/proctable'
|
31
|
+
include Sys
|
32
|
+
|
33
|
+
# Everything
|
34
|
+
ProcTable.ps{ |p|
|
35
|
+
puts p.pid.to_s
|
36
|
+
puts p.comm
|
37
|
+
...
|
38
|
+
}
|
39
|
+
|
40
|
+
or
|
41
|
+
|
42
|
+
# Just one process
|
43
|
+
s = ProcTable.ps(2123)
|
44
|
+
puts s.pid.to_s
|
45
|
+
puts s.comm
|
46
|
+
...
|
47
|
+
|
48
|
+
# Return the results as an array of ProcTableStructs
|
49
|
+
a = ProcTable.ps
|
50
|
+
a.each do |p|
|
51
|
+
puts a.pid
|
52
|
+
...
|
53
|
+
end
|
54
|
+
|
55
|
+
== Notes
|
56
|
+
Windows users may pass a host name as a second argument to get process
|
57
|
+
information from a different host. This relies on the WMI service running.
|
58
|
+
|
59
|
+
== Known Issues
|
60
|
+
=== BSD
|
61
|
+
A kvm interface is used. That means the owner of the process using the
|
62
|
+
sys-proctable library needs to be a member of the kvm group (or root).
|
63
|
+
|
64
|
+
=== Solaris
|
65
|
+
The cmdline member on Solaris is limited to 80 characters unless you (or
|
66
|
+
your program) own the process. This is a Solaris design flaw/feature.
|
67
|
+
|
68
|
+
=== OS X
|
69
|
+
At the moment you do not get the full command line string. The code required
|
70
|
+
to get this information is obnoxious and I don't have any compelling desire
|
71
|
+
to add it. However, if you're willing to submit a patch I'll accept it.
|
72
|
+
|
73
|
+
You can find a good starting point with the OS X code found in Dan Urist's
|
74
|
+
Proc::ProcessTable module. You can find that module on CPAN. Point your
|
75
|
+
browser at http://search.cpan.org.
|
76
|
+
|
77
|
+
=== Thread Safety
|
78
|
+
I am not currently using a thread-safe version of readdir(). I am not
|
79
|
+
especially concerned about it either. If you are trying to read information
|
80
|
+
out of /proc from different threads at the same time there is something
|
81
|
+
seriously wrong with your code logic. Using readdir_r() still won't solve
|
82
|
+
all potential thread safety issues anyway.
|
83
|
+
|
84
|
+
== Future Plans
|
85
|
+
Research has indicated that the kvm approach is less favored than a sysctl
|
86
|
+
approach on BSD variants. I will try to add this interface in a future
|
87
|
+
release.
|
88
|
+
|
89
|
+
== Acknowledgements
|
90
|
+
This library is largely based on the Perl module Proc::ProcessTable by
|
91
|
+
Dan Urist. Many ideas, as well as large chunks of code, were taken
|
92
|
+
from his work. So, a big THANK YOU goes out to Dan Urist.
|
93
|
+
|
94
|
+
A big thanks also goes out to Mike Hall who was very helpful with ideas,
|
95
|
+
logic and testing.
|
96
|
+
|
97
|
+
Thanks also go to Sean Chittenden for providing an account on one of his
|
98
|
+
FreeBSD machines. This is how the FreeBSD support was (initially) added.
|
99
|
+
|
100
|
+
Thanks go to James Hranicky for providing a patch that grabs name, eid,
|
101
|
+
euid, gid and guid info in the Linux version, along with some general
|
102
|
+
debugging help.
|
103
|
+
|
104
|
+
Thanks go to David Felstead for the original OS X code.
|
105
|
+
|
106
|
+
Finally I'd like to thank all the folks who have submitted bug reports
|
107
|
+
and/or patches.
|
108
|
+
|
109
|
+
== Help Wanted
|
110
|
+
I do not have access to all platforms. If your platform is not supported
|
111
|
+
then you will need to either submit a patch or give me a remote account
|
112
|
+
on a box with a compiler so that I can write the code.
|
113
|
+
|
114
|
+
== More documentation
|
115
|
+
See the documentation under the 'doc' directory for more information,
|
116
|
+
including platform specific notes and issues.
|
117
|
+
|
118
|
+
== License
|
119
|
+
Artistic 2.0
|
120
|
+
|
121
|
+
== Copyright
|
122
|
+
(C) 2003-2009 Daniel J. Berger
|
123
|
+
All Rights Reserved.
|
124
|
+
|
125
|
+
== Author
|
126
|
+
Daniel J. Berger
|
data/Rakefile
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rbconfig'
|
5
|
+
|
6
|
+
desc 'Clean the build files for C versions of sys-proctable'
|
7
|
+
task :clean do
|
8
|
+
rm_rf('.test-result') if File.exists?('.test-result')
|
9
|
+
Dir['*.gem'].each{ |f| File.delete(f) }
|
10
|
+
|
11
|
+
case Config::CONFIG['host_os']
|
12
|
+
when /bsd/i
|
13
|
+
dir = 'ext/bsd'
|
14
|
+
when /darwin/i
|
15
|
+
dir = 'ext/darwin'
|
16
|
+
when /hpux/i
|
17
|
+
dir = 'ext/hpux'
|
18
|
+
end
|
19
|
+
|
20
|
+
unless Config::CONFIG['host_os'] =~ /win32|mswin|dos|cygwin|mingw|linux|sunos|solaris/i
|
21
|
+
Dir.chdir(dir) do
|
22
|
+
if Dir['*.o'].length > 0
|
23
|
+
sh 'make distclean'
|
24
|
+
Dir['sys/proctable.*'].each{ |f| rm(f) if File.extname(f) != '.c' }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'Build the sys-proctable library for C versions of sys-proctable'
|
31
|
+
task :build => [:clean] do
|
32
|
+
case Config::CONFIG['host_os']
|
33
|
+
when /bsd/i
|
34
|
+
dir = 'ext/bsd'
|
35
|
+
when /darwin/i
|
36
|
+
dir = 'ext/darwin'
|
37
|
+
when /hpux/i
|
38
|
+
dir = 'ext/hpux'
|
39
|
+
end
|
40
|
+
|
41
|
+
unless Config::CONFIG['host_os'] =~ /win32|mswin|dos|cygwin|mingw|linux|sunos|solaris/i
|
42
|
+
Dir.chdir(dir) do
|
43
|
+
ruby 'extconf.rb'
|
44
|
+
sh 'make'
|
45
|
+
cp 'proctable.' + Config::CONFIG['DLEXT'], 'sys'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
desc 'Install the sys-proctable library'
|
51
|
+
task :install => [:build] do
|
52
|
+
file = nil
|
53
|
+
dir = File.join(Config::CONFIG['sitelibdir'], 'sys')
|
54
|
+
|
55
|
+
Dir.mkdir(dir) unless File.exists?(dir)
|
56
|
+
|
57
|
+
case Config::CONFIG['host_os']
|
58
|
+
when /mswin|win32|msdos|cygwin|mingw/i
|
59
|
+
file = 'lib/windows/sys/proctable.rb'
|
60
|
+
when /linux/i
|
61
|
+
file = 'lib/linux/sys/proctable.rb'
|
62
|
+
when /sunos|solaris/i
|
63
|
+
file = 'lib/sunos/sys/proctable.rb'
|
64
|
+
when /bsd/i
|
65
|
+
Dir.chdir('ext/bsd'){ sh 'make install' }
|
66
|
+
when /darwin/i
|
67
|
+
Dir.chdir('ext/darwin'){ sh 'make install' }
|
68
|
+
when /hpux/i
|
69
|
+
Dir.chdir('ext/hpux'){ sh 'make install' }
|
70
|
+
end
|
71
|
+
|
72
|
+
cp(file, dir, :verbose => true) if file
|
73
|
+
end
|
74
|
+
|
75
|
+
desc 'Uninstall the sys-proctable library'
|
76
|
+
task :uninstall do
|
77
|
+
case Config::CONFIG['host_os']
|
78
|
+
when /win32|mswin|dos|cygwin|mingw|linux|sunos|solaris/i
|
79
|
+
dir = File.join(Config::CONFIG['sitelibdir'], 'sys')
|
80
|
+
file = File.join(dir, 'proctable.rb')
|
81
|
+
else
|
82
|
+
dir = File.join(Config::CONFIG['sitearchdir'], 'sys')
|
83
|
+
file = File.join(dir, 'proctable.' + Config::CONFIG['DLEXT'])
|
84
|
+
end
|
85
|
+
|
86
|
+
rm(file)
|
87
|
+
end
|
88
|
+
|
89
|
+
desc 'Run the benchmark suite'
|
90
|
+
task :bench => [:build] do
|
91
|
+
sh "ruby -Ilib benchmarks/bench_ps.rb"
|
92
|
+
end
|
93
|
+
|
94
|
+
desc 'Run the example program'
|
95
|
+
task :example => [:build] do
|
96
|
+
sh 'ruby -Ilib -Iext examples/example_ps.rb'
|
97
|
+
end
|
98
|
+
|
99
|
+
desc 'Run the test suite'
|
100
|
+
Rake::TestTask.new do |t|
|
101
|
+
task :test => :build
|
102
|
+
t.libs << 'test'
|
103
|
+
|
104
|
+
case Config::CONFIG['host_os']
|
105
|
+
when /mswin|msdos|cygwin|mingw/i
|
106
|
+
t.test_files = FileList['test/test_sys_proctable_windows.rb']
|
107
|
+
t.libs << 'lib/windows'
|
108
|
+
when /linux/i
|
109
|
+
t.test_files = FileList['test/test_sys_proctable_linux.rb']
|
110
|
+
t.libs << 'lib/linux'
|
111
|
+
when /sunos|solaris/i
|
112
|
+
t.test_files = FileList['test/test_sys_proctable_sunos.rb']
|
113
|
+
t.libs << 'lib/sunos'
|
114
|
+
when /darwin/i
|
115
|
+
t.libs << 'ext/darwin'
|
116
|
+
t.test_files = FileList['test/test_sys_proctable_darwin.rb']
|
117
|
+
when /bsd/i
|
118
|
+
t.libs << 'ext/bsd'
|
119
|
+
t.test_files = FileList['test/test_sys_proctable_bsd.rb']
|
120
|
+
when /hpux/i
|
121
|
+
t.libs << 'ext/hpux'
|
122
|
+
t.test_files = FileList['test/test_sys_proctable_hpux.rb']
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
desc 'Create a gem'
|
127
|
+
task :gem do
|
128
|
+
spec = eval(IO.read('sys-proctable.gemspec'))
|
129
|
+
|
130
|
+
case Config::CONFIG['host_os']
|
131
|
+
when /bsd/i
|
132
|
+
spec.files << 'ext/bsd/sys/proctable.c'
|
133
|
+
spec.extra_rdoc_files << 'ext/bsd/sys/proctable.c'
|
134
|
+
spec.test_files << 'test/test_sys_proctable_bsd.rb'
|
135
|
+
spec.extensions = ['ext/bsd/extconf.rb']
|
136
|
+
when /darwin/i
|
137
|
+
spec.files << 'ext/darwin/sys/proctable.c'
|
138
|
+
spec.extra_rdoc_files << 'ext/darwin/sys/proctable.c'
|
139
|
+
spec.test_files << 'test/test_sys_proctable_darwin.rb'
|
140
|
+
spec.extensions = ['ext/darwin/extconf.rb']
|
141
|
+
when /hpux/i
|
142
|
+
spec.files << 'ext/hpux/sys/proctable.c'
|
143
|
+
spec.extra_rdoc_files << 'ext/hpux/sys/proctable.c'
|
144
|
+
spec.test_files << 'test/test_sys_proctable_hpux.rb'
|
145
|
+
spec.extensions = ['ext/hpux/extconf.rb']
|
146
|
+
when /linux/i
|
147
|
+
spec.require_paths = ['lib', 'lib/linux']
|
148
|
+
spec.files += ['lib/linux/sys/proctable.rb']
|
149
|
+
spec.test_files << 'test/test_sys_proctable_linux.rb'
|
150
|
+
when /sunos|solaris/i
|
151
|
+
spec.require_paths = ['lib', 'lib/sunos']
|
152
|
+
spec.files += ['lib/sunos/sys/proctable.rb']
|
153
|
+
spec.test_files << 'test/test_sys_proctable_sunos.rb'
|
154
|
+
when /mswin|win32|dos|cygwin|mingw/i
|
155
|
+
spec.require_paths = ['lib', 'lib/windows']
|
156
|
+
spec.files += ['lib/windows/sys/proctable.rb']
|
157
|
+
spec.test_files << 'test/test_sys_proctable_windows.rb'
|
158
|
+
end
|
159
|
+
|
160
|
+
Gem::Builder.new(spec).build
|
161
|
+
end
|
162
|
+
|
163
|
+
desc 'Install the sys-proctable library as a gem'
|
164
|
+
task :install_gem => [:gem] do
|
165
|
+
gem_name = Dir['*.gem'].first
|
166
|
+
sh "gem install #{gem_name}"
|
167
|
+
end
|