sys-proctable 0.9.2-universal-mingw32 → 0.9.3-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -1,112 +1,112 @@
1
- == Description
2
- A Ruby interface for gathering process information.
3
-
4
- == Prerequisites
5
- * Test::Unit 2.x (development only)
6
-
7
- == Supported Platforms
8
- * Windows 2000 or later
9
- * Linux 2.6+
10
- * BSD (various flavors)
11
- * Solaris 8+
12
- * HP-UX 10+
13
- * OS X 10.4+
14
-
15
- == Installation
16
- gem install sys-proctable
17
-
18
- You may need to specify a platform in some cases. For example:
19
-
20
- gem install sys-proctable --platform mswin32 # Windows
21
- gem install sys-proctable --platform sunos # Solaris
22
- gem install sys-proctable --platform linux # Linux
23
- gem install sys-proctable --platform freebsd # BSD (any flavor)
24
-
25
- == Synopsis
26
- require 'sys/proctable'
27
- include Sys
28
-
29
- # Everything
30
- ProcTable.ps{ |p|
31
- puts p.pid.to_s
32
- puts p.comm
33
- # ...
34
- }
35
-
36
- # Just one process
37
- s = ProcTable.ps(2123)
38
- puts s.pid.to_s
39
- puts s.comm
40
- # ...
41
-
42
- # Return the results as an array of ProcTableStructs
43
- a = ProcTable.ps
44
- a.each do |p|
45
- puts a.pid
46
- # ...
47
- end
48
-
49
- == Notes
50
- Windows users may pass a host name as a second argument to get process
51
- information from a different host. This relies on the WMI service running.
52
-
53
- == Known Issues
54
- === BSD
55
- A kvm interface is used. That means the owner of the process using the
56
- sys-proctable library needs to be a member of the kvm group (or root).
57
-
58
- === Solaris
59
- The cmdline member on Solaris is limited to 80 characters unless you (or
60
- your program) own the process. This is a Solaris design flaw/feature.
61
-
62
- === Thread Safety
63
- I am not currently using a thread-safe version of readdir() for versions
64
- of this library that use C. I am not especially concerned about it either.
65
- If you are trying to read information out of /proc from different threads
66
- at the same time there is something seriously wrong with your code logic.
67
- Using readdir_r() still won't solve all potential thread safety issues anyway.
68
-
69
- == Future Plans
70
- Research has indicated that the kvm approach is less favored than a sysctl
71
- approach on BSD variants. I will try to add this interface in a future
72
- release.
73
-
74
- == Acknowledgements
75
- This library is largely based on the Perl module Proc::ProcessTable by
76
- Dan Urist. Many ideas, as well as large chunks of code, were taken
77
- from his work. So, a big THANK YOU goes out to Dan Urist.
78
-
79
- A big thanks also goes out to Mike Hall who was very helpful with ideas,
80
- logic and testing.
81
-
82
- Thanks also go to Sean Chittenden for providing an account on one of his
83
- FreeBSD machines. This is how the FreeBSD support was (initially) added.
84
-
85
- Thanks go to James Hranicky for providing a patch that grabs name, eid,
86
- euid, gid and guid info in the Linux version, along with some general
87
- debugging help.
88
-
89
- Thanks go to David Felstead for the original OS X code. Thanks also go
90
- to Matthias Zirnstein for adding cmdline support for OS X.
91
-
92
- Finally I'd like to thank all the folks who have submitted bug reports
93
- and/or patches.
94
-
95
- == Help Wanted
96
- I do not have access to all platforms. If your platform is not supported
97
- then you will need to either submit a patch or give me a remote account
98
- on a box with a compiler so that I can write the code.
99
-
100
- == More documentation
101
- See the documentation under the 'doc' directory for more information,
102
- including platform specific notes and issues.
103
-
104
- == License
105
- Artistic 2.0
106
-
107
- == Copyright
108
- (C) 2003-2012 Daniel J. Berger
109
- All Rights Reserved.
110
-
111
- == Author
112
- Daniel J. Berger
1
+ == Description
2
+ A Ruby interface for gathering process information.
3
+
4
+ == Prerequisites
5
+ * Test::Unit 2.x (development only)
6
+
7
+ == Supported Platforms
8
+ * Windows 2000 or later
9
+ * Linux 2.6+
10
+ * BSD (various flavors)
11
+ * Solaris 8+
12
+ * HP-UX 10+
13
+ * OS X 10.4+
14
+
15
+ == Installation
16
+ gem install sys-proctable
17
+
18
+ You may need to specify a platform in some cases. For example:
19
+
20
+ gem install sys-proctable --platform mswin32 # Windows
21
+ gem install sys-proctable --platform sunos # Solaris
22
+ gem install sys-proctable --platform linux # Linux
23
+ gem install sys-proctable --platform freebsd # BSD (any flavor)
24
+
25
+ == Synopsis
26
+ require 'sys/proctable'
27
+ include Sys
28
+
29
+ # Everything
30
+ ProcTable.ps{ |p|
31
+ puts p.pid.to_s
32
+ puts p.comm
33
+ # ...
34
+ }
35
+
36
+ # Just one process
37
+ s = ProcTable.ps(2123)
38
+ puts s.pid.to_s
39
+ puts s.comm
40
+ # ...
41
+
42
+ # Return the results as an array of ProcTableStructs
43
+ a = ProcTable.ps
44
+ a.each do |p|
45
+ puts a.pid
46
+ # ...
47
+ end
48
+
49
+ == Notes
50
+ Windows users may pass a host name as a second argument to get process
51
+ information from a different host. This relies on the WMI service running.
52
+
53
+ == Known Issues
54
+ === BSD
55
+ A kvm interface is used. That means the owner of the process using the
56
+ sys-proctable library needs to be a member of the kvm group (or root).
57
+
58
+ === Solaris
59
+ The cmdline member on Solaris is limited to 80 characters unless you (or
60
+ your program) own the process. This is a Solaris design flaw/feature.
61
+
62
+ === Thread Safety
63
+ I am not currently using a thread-safe version of readdir() for versions
64
+ of this library that use C. I am not especially concerned about it either.
65
+ If you are trying to read information out of /proc from different threads
66
+ at the same time there is something seriously wrong with your code logic.
67
+ Using readdir_r() still won't solve all potential thread safety issues anyway.
68
+
69
+ == Future Plans
70
+ Research has indicated that the kvm approach is less favored than a sysctl
71
+ approach on BSD variants. I will try to add this interface in a future
72
+ release.
73
+
74
+ == Acknowledgements
75
+ This library is largely based on the Perl module Proc::ProcessTable by
76
+ Dan Urist. Many ideas, as well as large chunks of code, were taken
77
+ from his work. So, a big THANK YOU goes out to Dan Urist.
78
+
79
+ A big thanks also goes out to Mike Hall who was very helpful with ideas,
80
+ logic and testing.
81
+
82
+ Thanks also go to Sean Chittenden for providing an account on one of his
83
+ FreeBSD machines. This is how the FreeBSD support was (initially) added.
84
+
85
+ Thanks go to James Hranicky for providing a patch that grabs name, eid,
86
+ euid, gid and guid info in the Linux version, along with some general
87
+ debugging help.
88
+
89
+ Thanks go to David Felstead for the original OS X code. Thanks also go
90
+ to Matthias Zirnstein for adding cmdline support for OS X.
91
+
92
+ Finally I'd like to thank all the folks who have submitted bug reports
93
+ and/or patches.
94
+
95
+ == Help Wanted
96
+ I do not have access to all platforms. If your platform is not supported
97
+ then you will need to either submit a patch or give me a remote account
98
+ on a box with a compiler so that I can write the code.
99
+
100
+ == More documentation
101
+ See the documentation under the 'doc' directory for more information,
102
+ including platform specific notes and issues.
103
+
104
+ == License
105
+ Artistic 2.0
106
+
107
+ == Copyright
108
+ (C) 2003-2012 Daniel J. Berger
109
+ All Rights Reserved.
110
+
111
+ == Author
112
+ Daniel J. Berger
data/Rakefile CHANGED
@@ -1,174 +1,185 @@
1
- require 'rake'
2
- require 'rake/clean'
3
- require 'rake/testtask'
4
- require 'rbconfig'
5
- include RbConfig
6
-
7
- CLEAN.include(
8
- '**/*.core', # Core dump files
9
- '**/*.gem', # Gem files
10
- '**/*.rbc', # Rubinius
11
- '.rbx', '**/*/.rbx', # Rubinius
12
- '**/*.o', # C object file
13
- '**/*.log', # Ruby extension build log
14
- '**/Makefile', # C Makefile
15
- '**/conftest.dSYM', # OS X build directory
16
- "**/*.#{CONFIG['DLEXT']}" # C shared object
17
- )
18
-
19
- desc 'Build the sys-proctable library for C versions of sys-proctable'
20
- task :build => [:clean] do
21
- case CONFIG['host_os']
22
- when /bsd/i
23
- dir = 'ext/bsd'
24
- when /darwin/i
25
- dir = 'ext/darwin'
26
- when /hpux/i
27
- dir = 'ext/hpux'
28
- end
29
-
30
- unless CONFIG['host_os'] =~ /win32|mswin|dos|cygwin|mingw|windows|linux|sunos|solaris/i
31
- Dir.chdir(dir) do
32
- ruby 'extconf.rb'
33
- sh 'make'
34
- cp 'proctable.' + CONFIG['DLEXT'], 'sys'
35
- end
36
- end
37
- end
38
-
39
- desc 'Install the sys-proctable library'
40
- task :install => [:build] do
41
- file = nil
42
- dir = File.join(CONFIG['sitelibdir'], 'sys')
43
-
44
- Dir.mkdir(dir) unless File.exists?(dir)
45
-
46
- case CONFIG['host_os']
47
- when /mswin|win32|msdos|cygwin|mingw|windows/i
48
- file = 'lib/windows/sys/proctable.rb'
49
- when /linux/i
50
- file = 'lib/linux/sys/proctable.rb'
51
- when /sunos|solaris/i
52
- file = 'lib/sunos/sys/proctable.rb'
53
- when /bsd/i
54
- Dir.chdir('ext/bsd'){ sh 'make install' }
55
- when /darwin/i
56
- Dir.chdir('ext/darwin'){ sh 'make install' }
57
- when /hpux/i
58
- Dir.chdir('ext/hpux'){ sh 'make install' }
59
- end
60
-
61
- cp(file, dir, :verbose => true) if file
62
- end
63
-
64
- desc 'Uninstall the sys-proctable library'
65
- task :uninstall do
66
- case CONFIG['host_os']
67
- when /win32|mswin|dos|cygwin|mingw|windows|linux|sunos|solaris/i
68
- dir = File.join(CONFIG['sitelibdir'], 'sys')
69
- file = File.join(dir, 'proctable.rb')
70
- else
71
- dir = File.join(CONFIG['sitearchdir'], 'sys')
72
- file = File.join(dir, 'proctable.' + CONFIG['DLEXT'])
73
- end
74
-
75
- rm(file)
76
- end
77
-
78
- desc 'Run the benchmark suite'
79
- task :bench => [:build] do
80
- sh "ruby -Ilib benchmarks/bench_ps.rb"
81
- end
82
-
83
- desc 'Run the example program'
84
- task :example => [:build] do
85
- sh 'ruby -Ilib -Iext examples/example_ps.rb'
86
- end
87
-
88
- desc 'Run the test suite'
89
- Rake::TestTask.new do |t|
90
- task :test => :build
91
- t.libs << 'test' << '.'
92
-
93
- case CONFIG['host_os']
94
- when /mswin|msdos|cygwin|mingw|windows/i
95
- t.test_files = FileList['test/test_sys_proctable_windows.rb']
96
- t.libs << 'lib/windows'
97
- when /linux/i
98
- t.test_files = FileList['test/test_sys_proctable_linux.rb']
99
- t.libs << 'lib/linux'
100
- when /sunos|solaris/i
101
- t.test_files = FileList['test/test_sys_proctable_sunos.rb']
102
- t.libs << 'lib/sunos'
103
- when /darwin/i
104
- t.libs << 'ext/darwin'
105
- t.test_files = FileList['test/test_sys_proctable_darwin.rb']
106
- when /bsd/i
107
- t.libs << 'ext/bsd'
108
- t.test_files = FileList['test/test_sys_proctable_bsd.rb']
109
- when /hpux/i
110
- t.libs << 'ext/hpux'
111
- t.test_files = FileList['test/test_sys_proctable_hpux.rb']
112
- end
113
- end
114
-
115
- namespace :gem do
116
- desc 'Create a gem'
117
- task :create => [:clean] do
118
- spec = eval(IO.read('sys-proctable.gemspec'))
119
-
120
- # I've had to manually futz with the spec here in some cases
121
- # in order to get the universal platform settings I want because
122
- # of some bugginess in Rubygems' platform.rb.
123
- #
124
- case CONFIG['host_os']
125
- when /bsd/i
126
- spec.platform = Gem::Platform.new(['universal', 'freebsd'])
127
- spec.platform.version = nil
128
- spec.files << 'ext/bsd/sys/proctable.c'
129
- spec.extra_rdoc_files << 'ext/bsd/sys/proctable.c'
130
- spec.test_files << 'test/test_sys_proctable_bsd.rb'
131
- spec.extensions = ['ext/bsd/extconf.rb']
132
- when /darwin/i
133
- spec.platform = Gem::Platform.new(['universal', 'darwin'])
134
- spec.files << 'ext/darwin/sys/proctable.c'
135
- spec.extra_rdoc_files << 'ext/darwin/sys/proctable.c'
136
- spec.test_files << 'test/test_sys_proctable_darwin.rb'
137
- spec.extensions = ['ext/darwin/extconf.rb']
138
- when /hpux/i
139
- spec.platform = Gem::Platform.new(['universal', 'hpux'])
140
- spec.files << 'ext/hpux/sys/proctable.c'
141
- spec.extra_rdoc_files << 'ext/hpux/sys/proctable.c'
142
- spec.test_files << 'test/test_sys_proctable_hpux.rb'
143
- spec.extensions = ['ext/hpux/extconf.rb']
144
- when /linux/i
145
- spec.platform = Gem::Platform.new(['universal', 'linux'])
146
- spec.require_paths = ['lib', 'lib/linux']
147
- spec.files += ['lib/linux/sys/proctable.rb']
148
- spec.test_files << 'test/test_sys_proctable_linux.rb'
149
- when /sunos|solaris/i
150
- spec.platform = Gem::Platform.new(['universal', 'solaris'])
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|windows/i
155
- spec.platform = Gem::Platform.new(['universal', 'mingw32'])
156
- spec.require_paths = ['lib', 'lib/windows']
157
- spec.files += ['lib/windows/sys/proctable.rb']
158
- spec.test_files << 'test/test_sys_proctable_windows.rb'
159
- end
160
-
161
- # https://github.com/rubygems/rubygems/issues/147
162
- spec.original_platform = spec.platform
163
-
164
- Gem::Builder.new(spec).build
165
- end
166
-
167
- desc 'Install the sys-proctable library as a gem'
168
- task :install => [:create] do
169
- gem_name = Dir['*.gem'].first
170
- sh "gem install #{gem_name}"
171
- end
172
- end
173
-
174
- task :default => :test
1
+ require 'rake'
2
+ require 'rake/clean'
3
+ require 'rake/testtask'
4
+ require 'rbconfig'
5
+ include RbConfig
6
+
7
+ CLEAN.include(
8
+ '**/*.core', # Core dump files
9
+ '**/*.gem', # Gem files
10
+ '**/*.rbc', # Rubinius
11
+ '.rbx', '**/*/.rbx', # Rubinius
12
+ '**/*.o', # C object file
13
+ '**/*.log', # Ruby extension build log
14
+ '**/Makefile', # C Makefile
15
+ '**/conftest.dSYM', # OS X build directory
16
+ "**/*.#{CONFIG['DLEXT']}" # C shared object
17
+ )
18
+
19
+ desc 'Build the sys-proctable library for C versions of sys-proctable'
20
+ task :build => [:clean] do
21
+ if RUBY_PLATFORM == 'java'
22
+ if ENV['JRUBY_OPTS']
23
+ ENV['JRUBY_OPTS'] += ' -Xcext.enabled=true'
24
+ else
25
+ ENV['JRUBY_OPTS'] = '-Xcext.enabled=true'
26
+ end
27
+ end
28
+
29
+ case CONFIG['host_os']
30
+ when /bsd/i
31
+ dir = 'ext/bsd'
32
+ ext = '.so'
33
+ when /darwin/i
34
+ dir = 'ext/darwin'
35
+ ext = '.bundle'
36
+ when /hpux/i
37
+ dir = 'ext/hpux'
38
+ ext = '.sl'
39
+ end
40
+
41
+ unless CONFIG['host_os'] =~ /win32|mswin|dos|cygwin|mingw|windows|linux|sunos|solaris/i
42
+ Dir.chdir(dir) do
43
+ ruby 'extconf.rb'
44
+ sh 'make'
45
+ cp 'proctable' + ext, '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['sitelibdir'], 'sys')
54
+
55
+ Dir.mkdir(dir) unless File.exists?(dir)
56
+
57
+ case CONFIG['host_os']
58
+ when /mswin|win32|msdos|cygwin|mingw|windows/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['host_os']
78
+ when /win32|mswin|dos|cygwin|mingw|windows|linux|sunos|solaris/i
79
+ dir = File.join(CONFIG['sitelibdir'], 'sys')
80
+ file = File.join(dir, 'proctable.rb')
81
+ else
82
+ dir = File.join(CONFIG['sitearchdir'], 'sys')
83
+ file = File.join(dir, 'proctable.' + 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['host_os']
105
+ when /mswin|msdos|cygwin|mingw|windows/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
+ namespace :gem do
127
+ desc 'Create a gem'
128
+ task :create => [:clean] do
129
+ spec = eval(IO.read('sys-proctable.gemspec'))
130
+
131
+ # I've had to manually futz with the spec here in some cases
132
+ # in order to get the universal platform settings I want because
133
+ # of some bugginess in Rubygems' platform.rb.
134
+ #
135
+ case CONFIG['host_os']
136
+ when /bsd/i
137
+ spec.platform = Gem::Platform.new(['universal', 'freebsd'])
138
+ spec.platform.version = nil
139
+ spec.files << 'ext/bsd/sys/proctable.c'
140
+ spec.extra_rdoc_files << 'ext/bsd/sys/proctable.c'
141
+ spec.test_files << 'test/test_sys_proctable_bsd.rb'
142
+ spec.extensions = ['ext/bsd/extconf.rb']
143
+ when /darwin/i
144
+ spec.platform = Gem::Platform.new(['universal', 'darwin'])
145
+ spec.files << 'ext/darwin/sys/proctable.c'
146
+ spec.extra_rdoc_files << 'ext/darwin/sys/proctable.c'
147
+ spec.test_files << 'test/test_sys_proctable_darwin.rb'
148
+ spec.extensions = ['ext/darwin/extconf.rb']
149
+ when /hpux/i
150
+ spec.platform = Gem::Platform.new(['universal', 'hpux'])
151
+ spec.files << 'ext/hpux/sys/proctable.c'
152
+ spec.extra_rdoc_files << 'ext/hpux/sys/proctable.c'
153
+ spec.test_files << 'test/test_sys_proctable_hpux.rb'
154
+ spec.extensions = ['ext/hpux/extconf.rb']
155
+ when /linux/i
156
+ spec.platform = Gem::Platform.new(['universal', 'linux'])
157
+ spec.require_paths = ['lib', 'lib/linux']
158
+ spec.files += ['lib/linux/sys/proctable.rb']
159
+ spec.test_files << 'test/test_sys_proctable_linux.rb'
160
+ when /sunos|solaris/i
161
+ spec.platform = Gem::Platform.new(['universal', 'solaris'])
162
+ spec.require_paths = ['lib', 'lib/sunos']
163
+ spec.files += ['lib/sunos/sys/proctable.rb']
164
+ spec.test_files << 'test/test_sys_proctable_sunos.rb'
165
+ when /mswin|win32|dos|cygwin|mingw|windows/i
166
+ spec.platform = Gem::Platform.new(['universal', 'mingw32'])
167
+ spec.require_paths = ['lib', 'lib/windows']
168
+ spec.files += ['lib/windows/sys/proctable.rb']
169
+ spec.test_files << 'test/test_sys_proctable_windows.rb'
170
+ end
171
+
172
+ # https://github.com/rubygems/rubygems/issues/147
173
+ spec.original_platform = spec.platform
174
+
175
+ Gem::Builder.new(spec).build
176
+ end
177
+
178
+ desc 'Install the sys-proctable library as a gem'
179
+ task :install => [:create] do
180
+ gem_name = Dir['*.gem'].first
181
+ sh "gem install #{gem_name}"
182
+ end
183
+ end
184
+
185
+ task :default => :test