sys-proctable 0.8.0-x86-darwin-8

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES ADDED
@@ -0,0 +1,260 @@
1
+ == 0.8.0 - 26-Jan-2009
2
+ * The Linux and Solaris versions of this library are now pure Ruby. Be warned,
3
+ however, that only Solaris 8 and later are now supported. This may change
4
+ in a future release if there's demand to support 2.6 and 2.7.
5
+ * Some Struct::ProcTableStruct members have changed. As a general rule they
6
+ now more closely match the C struct member name. See individual platforms
7
+ for more details.
8
+ * Bug fix for the cmd_args struct member on Solaris.
9
+ * Bug fixes for OS X. Added a VERSION constant, fixed struct name, and changed
10
+ pct_cpu to pctcpu.
11
+ * The .new method is now explicitly illegal.
12
+ * The Struct::ProcTableStruct instances are now frozen. This is read-only data.
13
+ * Added the peak_page_file_usage and status members on MS Windows. The status
14
+ member is always nil, but was added for completeness.
15
+ * Fixed the quota_peak_paged_pool_usage member on MS Windows.
16
+ * ProcTableError is now ProcTable::Error.
17
+ * Minor test case fix for kvm/bsd based versions.
18
+ * Added the 'time' library as a require for Windows (to parse MS date/time
19
+ format strings).
20
+ * The kvm (bsd.c) implementation now works for FreeBSD 7.
21
+ * Added many more tests.
22
+ * Added some benchmarking code in the 'benchmarks' directory.
23
+ * Added a 'bench' Rake task.
24
+ * Renamed the test_ps.rb file to example_ps.rb in order to avoid any possible
25
+ confusion with actual test files.
26
+ * Added an 'example' rake task to run the example file.
27
+
28
+ == 0.7.6 - 11-Jul-2007
29
+ * Fixed the starttime for Linux. Thanks go to Yaroslav Dmitriev for the spot.
30
+ * Fixed a bug in the MS Windows version within a private method that parsed
31
+ an MS specific date format. This was caused by a backwards incompatible
32
+ change in the Time.parse method in Ruby 1.8.6. See ruby-core: 11245 ff.
33
+ * Fixed the gemspec (I hope). Please let me know if you have problems.
34
+ * Added a Rakefile. Building, testing and installing should now be handled via
35
+ Rake tasks. The install.rb file has been removed - that code is now
36
+ integrated in the Rakefile.
37
+ * Minor directory layout changes and cleanup (mostly for the extconf.rb file).
38
+ * Side note - it seems that the code for OS X *does* work, at least on 10.4.10.
39
+ I can only conclude that previous reports about it failing were related to
40
+ bugs in OS X or were really just build issues. Apologies (and thanks, again)
41
+ to David Felstead for the code. However, see the README for more information
42
+ specific to OS X, as there are shortcomings.
43
+
44
+ == 0.7.5 - 23-Nov-2006
45
+ * Fixed int/long issues for Linux. Thanks go to Matt Lightner for the spot.
46
+ * Minor documentation fixes and changes to the extconf.rb file.
47
+
48
+ == 0.7.4 - 20-Nov-2006
49
+ * Added a patch that deals with the large file compilation issue on Solaris.
50
+ You no longer need to build Ruby with --disable-largefile, or build a
51
+ 64 bit Ruby, in order for this package to work. Thanks go to Steven Jenkins
52
+ for the information that led to the patch.
53
+ * Added inline rdoc to the source code.
54
+ * Added a gemspec.
55
+ * Fixed some potential 64 bit issues (struct declarations).
56
+ * Added preliminary support for Darwin (OS X). The code was provided by
57
+ David Felstead, but does not appear to compile successfully. Help wanted.
58
+
59
+ == 0.7.3 - 27-Oct-2005
60
+ * Fix for 1.8.3 and later (rb_pid_t). This should have only affected
61
+ Solaris.
62
+
63
+ == 0.7.2 - 15-May-2005
64
+ * Bug fix for the FreeBSD version that reads from /proc.
65
+ * Eliminated the test bug on Linux (inexplicably caused by File.copy). The
66
+ test suite should now run without segfaulting.
67
+ * Include bsd.c in tarball (oops).
68
+ * Minor test updates for FreeBSD.
69
+ * The 'pct_cpu' member for the BSD/kvm version has been changed to 'pctcpu'
70
+ for consistency with other platforms.
71
+
72
+ == 0.7.1 - 8-May-2005
73
+ * Bug fixed for the cmdline info on Linux. Thanks go to Arash Abedinzadeh
74
+ for the spot.
75
+ * Added an example program.
76
+ * Minor setup fix for Win32 in tc_all.rb.
77
+
78
+ == 0.7.0 - 25-Apr-2005
79
+ * Scrapped the C implementation for Windows in favor of an OLE + WMI pure Ruby
80
+ approach. See documentation for details.
81
+ * Added an optional lkvm implementation for BSD users. This is automatically
82
+ used if the /proc filesystem isn't found.
83
+ * Added prusage info for the Solaris version.
84
+ * Added name, eid, euid, gid and guid information for Linux. Thanks go to
85
+ James Hranicky for the patch.
86
+ * Fixed some potential bugs in the Linux version. Thanks go to James
87
+ Hranicky for the spot.
88
+ * Added the 'sys/top' package.
89
+ * ProcTable.fields no longer supports a block form.
90
+ * The BTIME (boot time) information has been removed from the Linux version.
91
+ If you want that information, use sys-uptime instead.
92
+ * The .html and .rd files have been removed. You can generate html on your
93
+ own with rdoc if you like.
94
+ * Some code cleanup on the C side of the house.
95
+ * Most documents made rdoc friendly.
96
+ * Renamed 'install_pure_ruby.rb' to just 'install.rb'.
97
+ * Removed the 'INSTALL' file. Installation instructions are in the README.
98
+ * Some test suite cleanup and reorganization.
99
+ * Moved project to RubyForge.
100
+
101
+ == 0.6.4 - 31-Mar-2004
102
+ * Fixed a bug in the pure Ruby version for Win32. Thanks go to Mark Hudson
103
+ for the spot.
104
+ * Fixed a bug in the C implementation for Win32 where the cmdline and path
105
+ values were sometimes wrong for running processes. Thanks go to Park Heesob
106
+ for the fix.
107
+ * Updated the VERSION constant and removed the VERSION class method in the
108
+ pure Ruby version for Win32.
109
+ * Updated install_pure_ruby.rb and test.rb scripts.
110
+ * Updated warranty information.
111
+ * The extconf.rb script has been revamped. See the INSTALL and README files
112
+ for important changes since the last release.
113
+ * The start ProcInfo struct member on Solaris, HP-UX and FreeBSD is now a
114
+ Time object, not a Fixnum/Bignum.
115
+ * Modified linux.c yet again to make gcc happy when it comes to multi-line
116
+ string literals.
117
+ * Minor change to way process state is handled on HP-UX.
118
+ * Documentation additions and updates, including warranty information.
119
+
120
+ == 0.6.3 - 24-Feb-2004
121
+ * Fixed a bug in the Solaris version where the cmd_args array did not
122
+ necessarily contain data on 2.7 and later. The current patch still
123
+ does not quite fix the problem for 2.6 and earlier but can be easily
124
+ derived manually by parsing the cmdline string.
125
+
126
+ == 0.6.2 - 20-Jan-2004
127
+ * Fixed a small memory leak in the solaris version.
128
+
129
+ == 0.6.1 - 31-Dec-2003
130
+ * Fixed a minor bug in the cmdline field on Linux where a blank character
131
+ was being appended to the end of the field.
132
+ * Fixed a minor annoyance where the windows.rb file was being copied into
133
+ the Ruby lib directory on install.
134
+ * Added a test_memleak.rb file. Currently only supported on Linux and
135
+ only does a file descriptor count check. I plan to expand this to
136
+ other platforms in the future.
137
+ * Minor test suite changes
138
+ * MANIFEST correction and update.
139
+
140
+ == 0.6.0 - 22-Oct-2003
141
+ * Significant API change (and thus, a version jump) - only a
142
+ single argument is now accepted to the ps() method, and only a PID
143
+ (Fixnum) is regarded as a valid argument.
144
+ * Calling ps() with a pid returns a single ProcTable struct (or nil
145
+ if the pid is not found), instead of a one element array.
146
+ * Argument to ps() now works properly on HP-UX and Win32.
147
+ * Removed the '#include <sys/types32.h>' in sunos.h. It wasn't needed
148
+ and you're not supposed to include it directly.
149
+ * Fixed 2.6 compatibility issue with regards to cmdline on Solaris.
150
+ * Removed the ProcStatException completely on Linux. There was no reason
151
+ to fail on a directory read for /proc/xxx/stat. If the read fails
152
+ (meaning the process died in the middle of collecting info for it), it
153
+ is simply ignored.
154
+ * The ttynum bug on HPUX has been fixed. In addition, the return value for
155
+ this field is now a string rather than an int and the field name has
156
+ been changed to "ttydev".
157
+ * The ttynum field has been changed to ttydev on Solaris and HPUX. On
158
+ Solaris, the ttydev is now reported as -1 if there is no associated tty.
159
+ In a future release, Solaris and the other *nix platforms will be changed
160
+ so that ttydev is always a device name (i.e String).
161
+ * Added plain text documentation for all platforms.
162
+ * Some test suite cleanup.
163
+ * Changed .rd2 extension to just '.rd'.
164
+
165
+ == 0.5.2 - 18-Jul-2003
166
+ * Modified cmdline to extend past the traditional 80 character limit on
167
+ Solaris, where possible (Solaris 2.6+ only).
168
+ * Added the cmdline_args and num_args fields on Solaris, which returns
169
+ an array of cmdline arguments and the number of cmdline arguments,
170
+ respectively.
171
+ * Minor modification to fields() method, in addition to warning cleanup
172
+ for Solaris.
173
+ * Changed "defunct" state string to "zombie" for Solaris.
174
+ * Should cleanly compile with -Wall -W now (gcc) on Solaris.
175
+ * Added solaris.txt to doc directory.
176
+ * MANIFEST corrections.
177
+
178
+ == 0.5.1 - 16-Jul-2003
179
+ * Fixed a nasty file descriptor bug in the Linux code, where file descriptors
180
+ were continuously being used up.
181
+ * Added the BTIME (boot time) constant for Linux.
182
+ * Fixed up the test/test.rb file a bit.
183
+ * Added BTIME tests to tc_linux.rb.
184
+
185
+ == 0.5.0 - 11-Jul-200
186
+ * Added HP-UX support!
187
+ * Note that passing PID's or strings as arguments to ps() is not supported
188
+ in the HP-UX version. This functionality will be stripped out of the
189
+ other versions in a future release. See the README file for more details.
190
+ * Removed the VERSION() class method. Use the constant instead.
191
+ * Separated the rd docs from their respective source files. Now in the doc
192
+ directory.
193
+ * Got rid of the interactive html generation in extconf.rb.
194
+ * Changed License to Artistic.
195
+
196
+ == 0.4.3 - 30-May-2003
197
+ * Added a version.h file to store the version number. Modified all of the
198
+ C source files to use that instead of hard coding the version everywhere.
199
+ * Added a generic test.rb script for those without TestUnit installed, or
200
+ just futzing in general. Modified the extconf.rb script to copy this
201
+ instead of writing an inline HERE document.
202
+ * Modified extconf.rb so that it builds with mingw or cygwin. Thanks go to
203
+ Peter Fischer for the spot and patch.
204
+ * Modified test suite to work with TestUnit 0.1.6 or 0.1.8.
205
+
206
+ == 0.4.2 - 14-Apr-2003
207
+ * Added pure Ruby version for Win32 - thanks Park Heesob.
208
+ * Modified extconf.rb file to handle pure Ruby versions.
209
+ * Added install_pure_ruby.rb file, an alternate installation
210
+ script for pure Ruby versions.
211
+
212
+ == 0.4.1 - 31-Mar-2003
213
+ * Added support for Solaris 2.5.x.
214
+ * All exceptions are now a direct subclass of StandardError.
215
+ * Value returned for wchan now more meaningful (2.5.x only for now).
216
+ * Fixed the start, utime and ctime for FreeBSD.
217
+ * Minor fix to FreeBSD test suite.
218
+ * Some changes to extconf.rb.
219
+ * Minor doc changes.
220
+ * Added License and Copyright info.
221
+
222
+ == 0.4.0 - 10-Mar-2003
223
+ * Added MS Windows support (non-cygwin).
224
+ * Added environment information for Linux version.
225
+ * Added real exceptions (type depends on platform).
226
+ * Added a test suite (for those with testunit installed).
227
+ * Removed the sys-uname requirement.
228
+ * Heavily modified the extconf.rb script.
229
+ * Changed "Changelog" to "CHANGES" and "Manifest" to "MANIFEST".
230
+ * Added a VERSION constant and class method.
231
+ * Minor internal directory layout change (put 'os' under 'lib').
232
+ * Changed package name to lower case.
233
+ * Doc changes, including license information.
234
+
235
+ == 0.3.1 - 16-Aug-2002
236
+ * Added a "comm" field to the sunos version. I am going to try to make this a
237
+ common field for all platforms to help reduce RUBY_PLATFORM checking.
238
+ * Fixed the release date for 0.3.0 (was accidentally marked *July*).
239
+ * Added an INSTALL file.
240
+ * Minor documentation change to the sunos.c source file.
241
+
242
+ == 0.3.0 - 11-Aug-2002
243
+ * Added FreeBSD support!
244
+ * Struct name changed to just "ProcTableStruct" to be compliant with future
245
+ versions of Ruby.
246
+ * The ps() function now returns an array of ProcTableStruct's in lvalue context.
247
+ * Fixed the ability to search by process name in Linux.
248
+ * Modified Linux "comm" field to strip parenthesis.
249
+ * Some doc changes/additions.
250
+ * Added Sean Chittenden to the "Acknowledgements" section. Sean provided me
251
+ with access to a FreeBSD box, which is how I was able to provide FreeBSD
252
+ support. Thanks Sean!
253
+
254
+ == 0.2.0 - 19-Jul-2002
255
+ * Added the ability to search by process name.
256
+ * test.rb modified to be cross-platform.
257
+ * Solaris - fixed bug with fname (was accidentally called "name").
258
+
259
+ == 0.1.0 - 2-Jul-2002
260
+ - Initial release.
@@ -0,0 +1,38 @@
1
+ CHANGES
2
+ INSTALL
3
+ MANIFEST
4
+ Rakefile
5
+ sys-proctable.gemspec
6
+
7
+ doc/freebsd.txt
8
+ doc/hpux.txt
9
+ doc/linux.txt
10
+ doc/solaris.txt
11
+ doc/top.txt
12
+ doc/windows.txt
13
+
14
+ example/example_ps.rb
15
+
16
+ ext/extconf.rb
17
+ ext/bsd/bsd.c
18
+ ext/darwin/darwin.c
19
+ ext/freebsd/freebsd.c
20
+ ext/freebsd/freebsd.h
21
+ ext/hpux/hpux.c
22
+ ext/hpux/hpux.h
23
+ ext/version.h
24
+
25
+ lib/sys/top.rb
26
+ lib/sys/linux.rb
27
+ lib/sys/sunos.rb
28
+ lib/sys/windows.rb
29
+
30
+ test/test_sys_proctable_all.rb
31
+ test/test_sys_proctable_darwin.rb
32
+ test/test_sys_proctable_freebsd.rb
33
+ test/test_sys_proctable_hpux.rb
34
+ test/test_sys_proctable_kvm.rb
35
+ test/test_sys_proctable_linux.rb
36
+ test/test_sys_proctable_sunos.rb
37
+ test/test_sys_proctable_windows.rb
38
+ test/test_sys_top.rb
data/README ADDED
@@ -0,0 +1,137 @@
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
7
+
8
+ = Supported Platforms
9
+ * Windows NT family (NT, 2000, XP, etc)
10
+ * Linux
11
+ * FreeBSD
12
+ * Solaris 2.8+
13
+ * HP-UX
14
+ * OS X
15
+
16
+ = Installation
17
+ * rake test (optional)
18
+ * rake install
19
+
20
+ = Synopsis
21
+ require 'sys/proctable'
22
+ include Sys
23
+
24
+ # Everything
25
+ ProcTable.ps{ |p|
26
+ puts p.pid.to_s
27
+ puts p.comm
28
+ ...
29
+ }
30
+
31
+ or
32
+
33
+ # Just one process
34
+ s = ProcTable.ps(2123)
35
+ puts s.pid.to_s
36
+ puts s.comm
37
+ ...
38
+
39
+ # Return the results as an array of ProcTableStructs
40
+ a = ProcTable.ps
41
+ a.each do |p|
42
+ puts a.pid
43
+ ...
44
+ end
45
+
46
+ = Notes
47
+ Windows users may pass a host name as a second argument to get process
48
+ information from a different host. This relies on the WMI service running.
49
+
50
+ If you're building C source code, the ts_all.rb file is autogenerated for
51
+ you.
52
+
53
+ = Known Issues
54
+ === FreeBSD
55
+ If you're building on FreeBSD, a standard /proc filesystem read approach is
56
+ used if mounted. Otherwise, a kvm interface is used. There are more fields
57
+ available with the kvm interface, but keep in mind that you need to be a
58
+ member of the kvm group (or root) to use this. You can tweak the extconf.rb
59
+ file manually if you want to force the issue.
60
+
61
+ === OpenBSD, NetBSD
62
+ This library will attempt to use the kvm interface. It is untested,
63
+ however.
64
+
65
+ === Solaris
66
+ The cmdline member on Solaris is limited to 80 characters unless you (or
67
+ your program) own the process. This is a Solaris design flaw/feature.
68
+
69
+ === OS X
70
+ At the moment you do not get the full command line string. The code required
71
+ to get this information is obnoxious and I don't have any compelling desire
72
+ to add it. However, if you're willing to submit a patch I'll accept it.
73
+
74
+ You can find a good starting point with the OS X code found in Dan Urist's
75
+ Proc::ProcessTable module. You can find that module on CPAN. Point your
76
+ browser at http://search.cpan.org.
77
+
78
+ === Misc
79
+ If you build your library as a C extension (which is what will happen if
80
+ you run the 'build', 'test', or 'install' Rake tasks), then the .rb files
81
+ file under 'lib/sys/' are renamed to '.orig', except top.rb. This is
82
+ necessary to prevent mkmf from installing them during a 'make install'.
83
+
84
+ The 'clean' Rake task will rename them back to '.rb'.
85
+
86
+ === Thread Safety
87
+ I am not currently using a thread-safe version of readdir(). I am not
88
+ especially concerned about it either. If you are trying to read information
89
+ out of /proc from different threads at the same time there is something
90
+ seriously wrong with your code logic. Using readdir_r() still won't solve
91
+ all potential thread safety issues anyway.
92
+
93
+ = Future Plans
94
+ Research has indicated that the kvm approach is less favored than a sysctl
95
+ approach on BSD variants. I will try to add this interface in a future
96
+ release.
97
+
98
+ = Acknowledgements
99
+ This library is largely based on the Perl module Proc::ProcessTable by
100
+ Dan Urist. Many ideas, as well as large chunks of code, were taken
101
+ from his work. So, a big THANK YOU goes out to Dan Urist.
102
+
103
+ A big thanks also goes out to Mike Hall who was very helpful with ideas,
104
+ logic and testing.
105
+
106
+ Thanks also go to Sean Chittenden for providing an account on one of his
107
+ FreeBSD machines. This is how the FreeBSD support was (initially) added.
108
+
109
+ Thanks go to James Hranicky for providing a patch that grabs name, eid,
110
+ euid, gid and guid info in the Linux version, along with some general
111
+ debugging help.
112
+
113
+ Finally I'd like to thank all the folks who have submitted bug reports
114
+ and/or patches.
115
+
116
+ = Help Wanted
117
+ I do not have access to all platforms. There are a few other major platforms
118
+ out there, namely AIX, OpenBSD, and IRIX, among others, that I would
119
+ like to see ports for. There are two ways you can help - either submit code
120
+ for your particular platform or give me an account on your platform so I can
121
+ develop on it.
122
+
123
+ = More documentation
124
+ See the documentation under the 'doc' directory for more information,
125
+ including platform specific notes and issues.
126
+
127
+ = License
128
+ Ruby's
129
+
130
+ = Copyright
131
+ (C) 2003-2009 Daniel J. Berger
132
+ All Rights Reserved.
133
+
134
+ = Author
135
+ Daniel J. Berger
136
+ djberg96 at nospam at gmail dot com
137
+ imperator on IRC (Freenode)
@@ -0,0 +1,50 @@
1
+ = Description
2
+ A simple 'top' interface for Ruby
3
+
4
+ = Prerequisites
5
+ Requires the "sys/proctable" package (which should be installed along
6
+ with this package).
7
+
8
+ = Synopsis
9
+ require "sys/top"
10
+ include Sys
11
+
12
+ Top.top(5).each{ |ps|
13
+ p ps
14
+ }
15
+
16
+ = Constants
17
+ VERSION
18
+ Returns the version number of this package as a String.
19
+
20
+ = Class Methods
21
+ Top.top(number=10, field="pctcpu")
22
+ Returns an array of ProcTableStruct's. The size of the array (i.e. the
23
+ number of processes) that it returns is based on +number+, and sorted by
24
+ +pctcpu+. By default, the size and field values are 10 and "pctcpu",
25
+ respectively.
26
+
27
+ = Notes
28
+ Not all fields are available on all platforms. Please check your
29
+ platform specific documentation for which fields are available.
30
+
31
+ = Bugs
32
+ None that I'm aware of. Please log bug reports on the project page at
33
+ http://www.rubyforge.org/projects/sysutils
34
+
35
+ = License
36
+ Ruby's
37
+
38
+ = Copyright
39
+ (C) 2004-2009 Daniel J. Berger
40
+ All Rights Reserved.
41
+
42
+ = Warranty
43
+ This package is provided "as is" and without any express or
44
+ implied warranties, including, without limitation, the implied
45
+ warranties of merchantability and fitness for a particular purpose.
46
+
47
+ = Author
48
+ Daniel J. Berger
49
+ djberg96 at nospam at gmail dot com
50
+ imperator on IRC (Freenode)
@@ -0,0 +1,255 @@
1
+ /* Mac OS X code for Ruby Sys::ProcTable */
2
+ /* Date: 3-Mar-2006 (original submission date) */
3
+ /* Author: David Felstead (david.felstead at gmail dot com) */
4
+ /* Based on bsd.c by Daniel J. Berger (djberg96 at gmail dot com) */
5
+
6
+ #include "ruby.h"
7
+ #include "version.h"
8
+ #include <sys/param.h>
9
+ #include <sys/stat.h>
10
+ #include <sys/sysctl.h>
11
+ #include <sys/types.h>
12
+ #include <sys/user.h>
13
+ #include <errno.h>
14
+
15
+ #define PROC_MIB_LEN 4
16
+ #define ARGS_MIB_LEN 3
17
+ #define ARGS_MAX_LEN 4096
18
+ VALUE cProcTableError, sProcStruct;
19
+
20
+ char* fields[] = {
21
+ "pid", "ppid", "pgid", "ruid", "rgid", "comm", "state", "pctcpu", "oncpu",
22
+ "tnum", "tdev", "wmesg", "rtime", "priority", "usrpri", "nice", "cmdline",
23
+ "starttime", "maxrss", "ixrss", "idrss", "isrss", "minflt", "majflt",
24
+ "nswap", "inblock", "oublock", "msgsnd", "msgrcv", "nsignals", "nvcsw",
25
+ "nivcsw", "utime", "stime"
26
+ };
27
+
28
+ /*
29
+ * call-seq:
30
+ * ProcTable.ps(pid=nil)
31
+ * ProcTable.ps(pid=nil){ |ps| ... }
32
+ *
33
+ * In block form, yields a ProcTableStruct for each process entry that you
34
+ * have rights to. This method returns an array of ProcTableStruct's in
35
+ * non-block form.
36
+ *
37
+ * If a +pid+ is provided, then only a single ProcTableStruct is yielded or
38
+ * returned, or nil if no process information is found for that +pid+.
39
+ */
40
+ static VALUE pt_ps(int argc, VALUE* argv, VALUE klass){
41
+ int err;
42
+ char state[8];
43
+ struct kinfo_proc* procs;
44
+ int count; /* Holds total number of processes */
45
+ int i = 0;
46
+ VALUE v_pid, v_tty_num, v_tty_dev, v_start_time;
47
+ VALUE v_pstruct = Qnil;
48
+ VALUE v_array = rb_ary_new();
49
+ size_t length;
50
+ char args[ARGS_MAX_LEN+1];
51
+ /* Passed into sysctl call */
52
+ static const int name_mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0};
53
+
54
+ rb_scan_args(argc, argv, "01", &v_pid);
55
+
56
+ /* Get size of proc kproc buffer */
57
+ err = sysctl( (int *) name_mib, PROC_MIB_LEN, NULL, &length, NULL, 0);
58
+
59
+ /* TODO: Get error message from errno */
60
+ if(err == -1)
61
+ rb_raise(cProcTableError, strerror(errno));
62
+
63
+ /* Populate the kproc buffer */
64
+ procs = malloc(length);
65
+
66
+ if(procs == NULL) rb_raise(cProcTableError, strerror(errno));
67
+
68
+ err = sysctl( (int *) name_mib, PROC_MIB_LEN, procs, &length, NULL, 0);
69
+
70
+ /* TODO: Get error message from errno */
71
+ if(err == -1)
72
+ rb_raise(cProcTableError, strerror(errno));
73
+
74
+ /* If we're here, we got our list */
75
+ count = length / sizeof(struct kinfo_proc);
76
+
77
+ for(i=0; i<count; i++) {
78
+
79
+ /* Reset some variables */
80
+ v_tty_num = Qnil;
81
+ v_tty_dev = Qnil;
82
+ v_start_time = Qnil;
83
+
84
+ /* If a PID is provided, skip unless the PID matches */
85
+ if( (!NIL_P(v_pid)) && (procs[i].kp_proc.p_pid != NUM2INT(v_pid))) continue;
86
+
87
+ *args = '\0';
88
+
89
+ /* Query the command line args */
90
+ /* TODO: Cmd line not working for now - fix */
91
+
92
+ /*args_mib[ARGS_MIB_LEN - 1] = procs[i].kp_proc.p_pid;
93
+ args_err = sysctl( (int *) args_mib, ARGS_MIB_LEN, args, &args_size, NULL, 0);
94
+
95
+ if(args_err >= 0) {
96
+ fprintf(stderr, "Ret: %d LEN: %d\n", err, args_size);
97
+ char *c;
98
+ for(c = args; c < args+args_size; c++)
99
+ if(*c == '\0') *c = ' ';
100
+ args[args_size] = '\0';
101
+ } else {
102
+ fprintf(stderr, "err: %s LEN: %d\n", strerror(errno), args_size);
103
+ }*/
104
+
105
+ /* Get the start time of the process */
106
+ v_start_time = rb_time_new(
107
+ procs[i].kp_proc.p_un.__p_starttime.tv_sec,
108
+ procs[i].kp_proc.p_un.__p_starttime.tv_usec
109
+ );
110
+
111
+ /* Get the state of the process */
112
+ switch(procs[i].kp_proc.p_stat)
113
+ {
114
+ case SIDL:
115
+ strcpy(state, "idle");
116
+ break;
117
+ case SRUN:
118
+ strcpy(state, "run");
119
+ break;
120
+ case SSLEEP:
121
+ strcpy(state, "sleep");
122
+ break;
123
+ case SSTOP:
124
+ strcpy(state, "stop");
125
+ break;
126
+ case SZOMB:
127
+ strcpy(state, "zombie");
128
+ break;
129
+ default:
130
+ strcpy(state, "unknown");
131
+ break;
132
+ }
133
+
134
+ /* Get ttynum and ttydev. If ttynum is -1, there is no tty */
135
+ if(procs[i].kp_eproc.e_tdev != -1){
136
+ v_tty_num = INT2FIX(procs[i].kp_eproc.e_tdev),
137
+ v_tty_dev = rb_str_new2(devname(procs[i].kp_eproc.e_tdev, S_IFCHR));
138
+ }
139
+
140
+ v_pstruct = rb_struct_new(
141
+ sProcStruct,
142
+ INT2FIX(procs[i].kp_proc.p_pid),
143
+ INT2FIX(procs[i].kp_eproc.e_ppid),
144
+ INT2FIX(procs[i].kp_eproc.e_pgid),
145
+ INT2FIX(procs[i].kp_eproc.e_pcred.p_ruid),
146
+ INT2FIX(procs[i].kp_eproc.e_pcred.p_rgid),
147
+ rb_str_new2(procs[i].kp_proc.p_comm),
148
+ rb_str_new2(state),
149
+ rb_float_new(procs[i].kp_proc.p_pctcpu),
150
+ Qnil, //INT2FIX(procs[i].kp_proc.p_oncpu),
151
+ v_tty_num,
152
+ v_tty_dev,
153
+ rb_str_new2(procs[i].kp_eproc.e_wmesg),
154
+ INT2FIX(procs[i].kp_proc.p_rtime.tv_sec),
155
+ INT2FIX(procs[i].kp_proc.p_priority),
156
+ INT2FIX(procs[i].kp_proc.p_usrpri),
157
+ INT2FIX(procs[i].kp_proc.p_nice),
158
+ rb_str_new2(args),
159
+ v_start_time,
160
+ /* For some processes, p_ru is NULL */
161
+ procs[i].kp_proc.p_ru ? LONG2NUM(procs[i].kp_proc.p_ru->ru_maxrss) : Qnil,
162
+ procs[i].kp_proc.p_ru ? LONG2NUM(procs[i].kp_proc.p_ru->ru_ixrss) : Qnil,
163
+ procs[i].kp_proc.p_ru ? LONG2NUM(procs[i].kp_proc.p_ru->ru_idrss) : Qnil,
164
+ procs[i].kp_proc.p_ru ? LONG2NUM(procs[i].kp_proc.p_ru->ru_isrss) : Qnil,
165
+ procs[i].kp_proc.p_ru ? LONG2NUM(procs[i].kp_proc.p_ru->ru_minflt) : Qnil,
166
+ procs[i].kp_proc.p_ru ? LONG2NUM(procs[i].kp_proc.p_ru->ru_majflt) : Qnil,
167
+ procs[i].kp_proc.p_ru ? LONG2NUM(procs[i].kp_proc.p_ru->ru_nswap) : Qnil,
168
+ procs[i].kp_proc.p_ru ? LONG2NUM(procs[i].kp_proc.p_ru->ru_inblock) : Qnil,
169
+ procs[i].kp_proc.p_ru ? LONG2NUM(procs[i].kp_proc.p_ru->ru_oublock) : Qnil,
170
+ procs[i].kp_proc.p_ru ? LONG2NUM(procs[i].kp_proc.p_ru->ru_msgsnd) : Qnil,
171
+ procs[i].kp_proc.p_ru ? LONG2NUM(procs[i].kp_proc.p_ru->ru_msgrcv) : Qnil,
172
+ procs[i].kp_proc.p_ru ? LONG2NUM(procs[i].kp_proc.p_ru->ru_nsignals) : Qnil,
173
+ procs[i].kp_proc.p_ru ? LONG2NUM(procs[i].kp_proc.p_ru->ru_nvcsw) : Qnil,
174
+ procs[i].kp_proc.p_ru ? LONG2NUM(procs[i].kp_proc.p_ru->ru_nivcsw) : Qnil,
175
+ procs[i].kp_proc.p_ru ? LONG2NUM(procs[i].kp_proc.p_ru->ru_utime.tv_sec) : Qnil,
176
+ procs[i].kp_proc.p_ru ? LONG2NUM(procs[i].kp_proc.p_ru->ru_stime.tv_sec) : Qnil
177
+ );
178
+
179
+ OBJ_FREEZE(v_pstruct); // This is read-only data
180
+
181
+ if(rb_block_given_p())
182
+ rb_yield(v_pstruct);
183
+ else
184
+ rb_ary_push(v_array, v_pstruct);
185
+ }
186
+
187
+ if(procs) free(procs);
188
+
189
+ if(!rb_block_given_p()){
190
+ if(NIL_P(v_pid))
191
+ return v_array;
192
+ else
193
+ return v_pstruct;
194
+ }
195
+
196
+ return Qnil;
197
+ }
198
+
199
+ /*
200
+ * call-seq:
201
+ * ProcTable.fields
202
+ *
203
+ * Returns an array of fields that each ProcTableStruct will contain. This
204
+ * may be useful if you want to know in advance what fields are available
205
+ * without having to perform at least one read of the /proc table.
206
+ */
207
+ static VALUE pt_fields(VALUE klass){
208
+ VALUE v_array = rb_ary_new();
209
+ int size = sizeof(fields) / sizeof(fields[0]);
210
+ int i;
211
+
212
+ for(i = 0; i < size; i++)
213
+ rb_ary_push(v_array, rb_str_new2(fields[i]));
214
+
215
+ return v_array;
216
+ }
217
+
218
+ /*
219
+ * A Ruby interface for gathering process table information.
220
+ */
221
+ void Init_proctable(){
222
+ VALUE mSys, cProcTable;
223
+
224
+ /* The Sys module serves as a namespace only */
225
+ mSys = rb_define_module("Sys");
226
+
227
+ /* The ProcTable class encapsulates process table information */
228
+ cProcTable = rb_define_class_under(mSys, "ProcTable", rb_cObject);
229
+
230
+ /* The Error class typically raised if any of the ProcTable methods fail */
231
+ cProcTableError = rb_define_class_under(cProcTable, "Error", rb_eStandardError);
232
+
233
+ /* Singleton methods */
234
+
235
+ rb_define_singleton_method(cProcTable, "ps", pt_ps, -1);
236
+ rb_define_singleton_method(cProcTable, "fields", pt_fields, 0);
237
+
238
+ /* There is no constructor */
239
+ rb_funcall(cProcTable, rb_intern("private_class_method"), 1, ID2SYM(rb_intern("new")));
240
+
241
+ /* Constants */
242
+
243
+ /* 0.8.0: The version of this library */
244
+ rb_define_const(cProcTable, "VERSION", rb_str_new2(SYS_PROCTABLE_VERSION));
245
+
246
+ /* Structures */
247
+
248
+ sProcStruct = rb_struct_define("ProcTableStruct","pid","ppid","pgid","ruid",
249
+ "rgid","comm","state","pctcpu","oncpu","tnum","tdev","wmesg",
250
+ "rtime", "priority","usrpri","nice","cmdline","starttime",
251
+ "maxrss","ixrss","idrss","isrss","minflt","majflt","nswap",
252
+ "inblock","oublock","msgsnd","msgrcv","nsignals","nvcsw","nivcsw",
253
+ "utime","stime", NULL
254
+ );
255
+ }
@@ -0,0 +1,78 @@
1
+ #############################################################################
2
+ # Installation script for sys-proctable.
3
+ #
4
+ # By running this file, it is assumed that you want a C extension, and not
5
+ # a pure Ruby version. If you want a pure Ruby version (and you're on a
6
+ # platform for which it's supported), run install.rb instead.
7
+ #############################################################################
8
+ require 'mkmf'
9
+ require 'fileutils'
10
+ require 'rbconfig'
11
+
12
+ c_file = nil
13
+ h_file = nil
14
+
15
+ ########################################################################
16
+ # Ruby 1.8.3 and later mandates the use of rb_pid_t over pid_t because
17
+ # some libraries define their own pid_t. So, we check for that.
18
+ ########################################################################
19
+ have_type('rb_pid_t', 'ruby.h')
20
+
21
+ ##########################################################################
22
+ # Determine appropriate source files based on platform. Also, check for
23
+ # certain header files and/or libraries on some platforms.
24
+ #
25
+ # FreeBSD has its own source file if /proc is mounted and contains data.
26
+ # Otherwise it uses the kvm interface. All other BSD platforms always use
27
+ # the kvm interface.
28
+ ##########################################################################
29
+ case Config::CONFIG['host_os']
30
+ when /hpux/i
31
+ c_file = 'hpux/hpux.c'
32
+ h_file = 'hpux/hpux.h'
33
+ when /bsd/i
34
+ if Config::CONFIG['host_os'].match('freebsd') && Dir['/proc/*'].length > 0
35
+ c_file = 'freebsd/freebsd.c'
36
+ h_file = 'freebsd/freebsd.h'
37
+ else
38
+ have_library('kvm')
39
+ have_func('kvm_openfiles')
40
+ have_struct_member('struct kinfo_proc', 'kp_proc', 'sys/user.h')
41
+ have_struct_member('struct kinfo_proc', 'kp_eproc', 'sys/user.h')
42
+ have_struct_member('struct kinfo_proc', 'u_kproc', 'sys/user.h')
43
+ have_struct_member('struct eproc', 'e_stats', 'sys/sysctl.h')
44
+ have_struct_member('struct eproc', 'p_oncpu', 'sys/sysctl.h')
45
+ have_struct_member('struct eproc', 'p_runtime', 'sys/sysctl.h')
46
+ c_file = 'bsd/bsd.c'
47
+ end
48
+ when /darwin/i
49
+ c_file = 'darwin/darwin.c'
50
+ when /windows|mswin|cygwin|mingw|dos|linux|sunos|solaris/i
51
+ STDERR.puts "Use the 'rake install' task to install pure Ruby versions"
52
+ exit
53
+ else
54
+ STDERR.puts 'This platform not currently supported. Exiting...'
55
+ exit
56
+ end
57
+
58
+ #####################################################################
59
+ # Move the '.rb' files under 'lib/sys/' to '.orig' to prevent
60
+ # mkmf from installing them during the 'make install' phase.
61
+ #####################################################################
62
+ Dir.chdir("../lib/sys"){
63
+ Dir["*.rb"].each{ |file|
64
+ next if file == 'top.rb'
65
+ File.rename(file, File.basename(file, '.rb') + '.orig')
66
+ }
67
+ }
68
+
69
+ ########################################################################
70
+ # Copy or link files to current directory for create_makefile to work.
71
+ ########################################################################
72
+ File.delete('proctable.c') rescue nil
73
+ File.delete(File.basename(h_file)) rescue nil
74
+
75
+ FileUtils.cp(c_file, 'proctable.c')
76
+ FileUtils.cp(h_file, File.basename(h_file)) if h_file
77
+
78
+ create_makefile('sys/proctable')
@@ -0,0 +1,2 @@
1
+ /* version.h - stores the version number for all platforms (that use C) */
2
+ #define SYS_PROCTABLE_VERSION "0.8.0"
@@ -0,0 +1,35 @@
1
+ require 'sys/proctable'
2
+ require 'rbconfig'
3
+
4
+ # The Sys module serves as a namespace only
5
+ module Sys
6
+
7
+ # The Top class serves as a toplevel name for the 'top' method.
8
+ class Top
9
+
10
+ # The version of the sys-top library
11
+ VERSION = '1.0.2'
12
+
13
+ # Returns an array of Struct::ProcTableStruct elements containing up
14
+ # to +num+ elements, sorted by +field+. The default number of elements
15
+ # is 10, while the default field is 'pctcpu'.
16
+ #
17
+ # Exception: the default sort field is 'pid' on Linux and Windows.
18
+ #
19
+ def self.top(num=10, field='pctcpu')
20
+ field = field.to_s if field.is_a?(Symbol)
21
+
22
+ # Sort by pid on Windows by default
23
+ if Config::CONFIG['host_os'].match('mswin') && field == 'pctcpu'
24
+ field = 'pid'
25
+ end
26
+
27
+ # Linux does not have a pctcpu field yet
28
+ if Config::CONFIG['host_os'].match('linux') && field == 'pctcpu'
29
+ field = 'pid'
30
+ end
31
+
32
+ Sys::ProcTable.ps.sort_by{ |obj| obj.send(field) || '' }[0..num-1]
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,80 @@
1
+ #######################################################################
2
+ # test_sys_proctable_all.rb
3
+ #
4
+ # Test suite for methods common to all platforms. Generally speaking
5
+ # you should run this test case using the 'rake test' task.
6
+ #######################################################################
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
10
+ require 'test/unit'
11
+ require 'sys/proctable'
12
+ require 'rbconfig'
13
+ require 'test/test_sys_top'
14
+ include Sys
15
+
16
+ class TC_ProcTable_All < Test::Unit::TestCase
17
+ def self.startup
18
+ @@windows = Config::CONFIG['host_os'].match('mswin')
19
+ end
20
+
21
+ def setup
22
+ @pid = @@windows ? 0 : 1
23
+ end
24
+
25
+ def test_version
26
+ assert_equal('0.8.0', ProcTable::VERSION)
27
+ end
28
+
29
+ def test_fields
30
+ assert_respond_to(ProcTable, :fields)
31
+ assert_nothing_raised{ ProcTable.fields }
32
+ assert_kind_of(Array, ProcTable.fields)
33
+ assert_kind_of(String, ProcTable.fields.first)
34
+ end
35
+
36
+ def test_ps
37
+ assert_respond_to(ProcTable, :ps)
38
+ assert_nothing_raised{ ProcTable.ps }
39
+ assert_nothing_raised{ ProcTable.ps{} }
40
+ end
41
+
42
+ def test_ps_with_pid
43
+ assert_nothing_raised{ ProcTable.ps(0) }
44
+ end
45
+
46
+ def test_ps_with_explicit_nil
47
+ assert_nothing_raised{ ProcTable.ps(nil) }
48
+ assert_kind_of(Array, ProcTable.ps(nil))
49
+ end
50
+
51
+ def test_ps_return_value
52
+ assert_kind_of(Array, ProcTable.ps)
53
+ assert_kind_of(Struct::ProcTableStruct, ProcTable.ps(@pid))
54
+ assert_equal(nil, ProcTable.ps(999999999))
55
+ assert_equal(nil, ProcTable.ps(999999999){})
56
+ assert_equal(nil, ProcTable.ps{})
57
+ end
58
+
59
+ def test_ps_returned_struct_is_frozen
60
+ assert_true(ProcTable.ps.first.frozen?)
61
+ end
62
+
63
+ def test_ps_expected_errors
64
+ assert_raises(TypeError){ ProcTable.ps('vim') }
65
+ omit_if(@@windows, 'ArgumentError check skipped on MS Windows')
66
+ assert_raises(ArgumentError){ ProcTable.ps(0, 'localhost') }
67
+ end
68
+
69
+ def test_new_not_allowed
70
+ assert_raise(NoMethodError){ Sys::ProcTable.new }
71
+ end
72
+
73
+ def teardown
74
+ @pid = nil
75
+ end
76
+
77
+ def self.teardown
78
+ @@windows = nil
79
+ end
80
+ end
@@ -0,0 +1,228 @@
1
+ ########################################################################
2
+ # test_sys_proctable_darwin.
3
+ #
4
+ # Test suite for the Darwin version of the sys-proctable library. You
5
+ # should run these tests via the 'rake test' task.
6
+ ########################################################################
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
10
+ require 'sys/proctable'
11
+ require 'test/test_sys_proctable_all'
12
+ include Sys
13
+
14
+ class TC_ProcTable_Darwin < Test::Unit::TestCase
15
+ def self.startup
16
+ @@fields = %w/
17
+ pid ppid pgid ruid rgid comm state pctcpu oncpu tnum
18
+ tdev wmesg rtime priority usrpri nice cmdline starttime
19
+ maxrss ixrss idrss isrss minflt majflt nswap inblock oublock
20
+ msgsnd msgrcv nsignals nvcsw nivcsw utime stime
21
+ /
22
+ end
23
+
24
+ def setup
25
+ @ptable = ProcTable.ps.last
26
+ end
27
+
28
+ def test_fields
29
+ assert_respond_to(ProcTable, :fields)
30
+ assert_kind_of(Array, ProcTable.fields)
31
+ assert_equal(@@fields, ProcTable.fields)
32
+ end
33
+
34
+ def test_pid
35
+ assert_respond_to(@ptable, :pid)
36
+ assert_kind_of(Fixnum, @ptable.pid)
37
+ end
38
+
39
+ def test_ppid
40
+ assert_respond_to(@ptable, :ppid)
41
+ assert_kind_of(Fixnum, @ptable.ppid)
42
+ end
43
+
44
+ def test_pgid
45
+ assert_respond_to(@ptable, :pgid)
46
+ assert_kind_of(Fixnum, @ptable.pgid)
47
+ end
48
+
49
+ def test_ruid
50
+ assert_respond_to(@ptable, :ruid)
51
+ assert_kind_of(Fixnum, @ptable.ruid)
52
+ end
53
+
54
+ def test_rgid
55
+ assert_respond_to(@ptable, :rgid)
56
+ assert_kind_of(Fixnum, @ptable.rgid)
57
+ end
58
+
59
+ def test_comm
60
+ assert_respond_to(@ptable, :comm)
61
+ assert_kind_of(String, @ptable.comm)
62
+ assert_true(@ptable.comm.length > 0)
63
+ end
64
+
65
+ def test_state
66
+ assert_respond_to(@ptable, :state)
67
+ assert_kind_of(String, @ptable.state)
68
+ assert_true(%w/idle run sleep stop zombie unknown/.include?(@ptable.state))
69
+ end
70
+
71
+ def test_pctcpu
72
+ assert_respond_to(@ptable, :pctcpu)
73
+ assert_kind_of(Float, @ptable.pctcpu)
74
+ end
75
+
76
+ def test_oncpu
77
+ assert_respond_to(@ptable, :oncpu)
78
+ omit("oncpu always nil for now")
79
+ end
80
+
81
+ def test_tnum
82
+ assert_respond_to(@ptable, :tnum)
83
+ #assert_kind_of(Fixnum, @ptable.tnum)
84
+ end
85
+
86
+ def test_tdev
87
+ assert_respond_to(@ptable, :tdev)
88
+ #assert_kind_of(String, @ptable.tdev)
89
+ end
90
+
91
+ def test_wmesg
92
+ assert_respond_to(@ptable, :wmesg)
93
+ assert_kind_of(String, @ptable.wmesg)
94
+ end
95
+
96
+ def test_rtime
97
+ assert_respond_to(@ptable, :rtime)
98
+ assert_kind_of(Fixnum, @ptable.rtime)
99
+ end
100
+
101
+ def test_priority
102
+ assert_respond_to(@ptable, :priority)
103
+ assert_kind_of(Fixnum, @ptable.priority)
104
+ end
105
+
106
+ def test_usrpri
107
+ assert_respond_to(@ptable, :usrpri)
108
+ assert_kind_of(Fixnum, @ptable.usrpri)
109
+ end
110
+
111
+ def test_nice
112
+ assert_respond_to(@ptable, :nice)
113
+ assert_kind_of(Fixnum, @ptable.nice)
114
+ end
115
+
116
+ def test_priority
117
+ assert_respond_to(@ptable, :priority)
118
+ assert_kind_of(Fixnum, @ptable.priority)
119
+ end
120
+
121
+ def test_usrpri
122
+ assert_respond_to(@ptable, :usrpri)
123
+ assert_kind_of(Fixnum, @ptable.usrpri)
124
+ end
125
+
126
+ def test_nice
127
+ assert_respond_to(@ptable, :nice)
128
+ assert_kind_of(Fixnum, @ptable.nice)
129
+ end
130
+
131
+ def test_cmdline
132
+ assert_respond_to(@ptable, :cmdline)
133
+ assert_kind_of(String, @ptable.cmdline)
134
+ end
135
+
136
+ def test_starttime
137
+ assert_respond_to(@ptable, :starttime)
138
+ assert_kind_of(Time, @ptable.starttime)
139
+ end
140
+
141
+ def test_maxrss
142
+ assert_respond_to(@ptable, :maxrss)
143
+ assert_true([NilClass, Fixnum].include?(@ptable.maxrss.class))
144
+ end
145
+
146
+ def test_ixrss
147
+ assert_respond_to(@ptable, :ixrss)
148
+ assert_true([NilClass, Fixnum].include?(@ptable.ixrss.class))
149
+ end
150
+
151
+ def test_idrss
152
+ assert_respond_to(@ptable, :idrss)
153
+ assert_true([NilClass, Fixnum].include?(@ptable.idrss.class))
154
+ end
155
+
156
+ def test_isrss
157
+ assert_respond_to(@ptable, :isrss)
158
+ assert_true([NilClass, Fixnum].include?(@ptable.isrss.class))
159
+ end
160
+
161
+ def test_minflt
162
+ assert_respond_to(@ptable, :minflt)
163
+ assert_true([NilClass, Fixnum].include?(@ptable.minflt.class))
164
+ end
165
+
166
+ def test_majflt
167
+ assert_respond_to(@ptable, :majflt)
168
+ assert_true([NilClass, Fixnum].include?(@ptable.majflt.class))
169
+ end
170
+
171
+ def test_nswap
172
+ assert_respond_to(@ptable, :nswap)
173
+ assert_true([NilClass, Fixnum].include?(@ptable.nswap.class))
174
+ end
175
+
176
+ def test_inblock
177
+ assert_respond_to(@ptable, :inblock)
178
+ assert_true([NilClass, Fixnum].include?(@ptable.inblock.class))
179
+ end
180
+
181
+ def test_oublock
182
+ assert_respond_to(@ptable, :oublock)
183
+ assert_true([NilClass, Fixnum].include?(@ptable.oublock.class))
184
+ end
185
+
186
+ def test_msgsnd
187
+ assert_respond_to(@ptable, :msgsnd)
188
+ assert_true([NilClass, Fixnum].include?(@ptable.msgsnd.class))
189
+ end
190
+
191
+ def test_msgrcv
192
+ assert_respond_to(@ptable, :msgrcv)
193
+ assert_true([NilClass, Fixnum].include?(@ptable.msgrcv.class))
194
+ end
195
+
196
+ def test_nsignals
197
+ assert_respond_to(@ptable, :nsignals)
198
+ assert_true([NilClass, Fixnum].include?(@ptable.nsignals.class))
199
+ end
200
+
201
+ def test_nvcsw
202
+ assert_respond_to(@ptable, :nvcsw)
203
+ assert_true([NilClass, Fixnum].include?(@ptable.nvcsw.class))
204
+ end
205
+
206
+ def test_nivcsw
207
+ assert_respond_to(@ptable, :nivcsw)
208
+ assert_true([NilClass, Fixnum].include?(@ptable.nivcsw.class))
209
+ end
210
+
211
+ def test_utime
212
+ assert_respond_to(@ptable, :utime)
213
+ assert_true([NilClass, Fixnum].include?(@ptable.utime.class))
214
+ end
215
+
216
+ def test_stime
217
+ assert_respond_to(@ptable, :stime)
218
+ assert_true([NilClass, Fixnum].include?(@ptable.stime.class))
219
+ end
220
+
221
+ def teardown
222
+ @ptable = nil
223
+ end
224
+
225
+ def self.shutdown
226
+ @@fields = nil
227
+ end
228
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sys-proctable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.8.0
5
+ platform: x86-darwin-8
6
+ authors:
7
+ - Daniel J. Berger
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-26 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: test-unit
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.0.2
24
+ version:
25
+ description: An interface for providing process table information
26
+ email: djberg96@gmail.com
27
+ executables: []
28
+
29
+ extensions:
30
+ - ext/extconf.rb
31
+ extra_rdoc_files:
32
+ - CHANGES
33
+ - README
34
+ - MANIFEST
35
+ - doc/top.txt
36
+ - ext/darwin/darwin.c
37
+ files:
38
+ - lib/sys/top.rb
39
+ - test/test_sys_proctable_all.rb
40
+ - test/test_sys_proctable_darwin.rb
41
+ - CHANGES
42
+ - README
43
+ - MANIFEST
44
+ - doc/top.txt
45
+ - ext/darwin/darwin.c
46
+ - ext/extconf.rb
47
+ - ext/version.h
48
+ has_rdoc: true
49
+ homepage: http://www.rubyforge.org/projects/sysutils
50
+ licenses: []
51
+
52
+ post_install_message:
53
+ rdoc_options: []
54
+
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: "0"
62
+ version:
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ version:
69
+ requirements: []
70
+
71
+ rubyforge_project: sysutils
72
+ rubygems_version: 1.3.1
73
+ signing_key:
74
+ specification_version: 3
75
+ summary: An interface for providing process table information
76
+ test_files:
77
+ - test/test_sys_proctable_all.rb
78
+ - test/test_sys_proctable_darwin.rb