win32-process 0.6.6 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,69 +13,19 @@
13
13
  ###############################################################################
14
14
  require 'test-unit'
15
15
  require 'win32/process'
16
- require 'sys/proctable'
17
16
 
18
17
  class TC_Win32Process < Test::Unit::TestCase
19
-
20
- # Start two instances of notepad and give them a chance to fire up
21
18
  def self.startup
22
- IO.popen('notepad')
23
- IO.popen('notepad')
24
- sleep 1 # Give the notepad instances a second to startup
25
-
26
- @@pids = []
27
-
28
- Sys::ProcTable.ps{ |struct|
29
- next unless struct.comm =~ /notepad/i
30
- @@pids << struct.pid
31
- }
19
+ @@pids = []
20
+ @@jruby = RUBY_PLATFORM == 'java'
32
21
  end
33
22
 
34
23
  def setup
35
- @pri_class = Process::NORMAL_PRIORITY_CLASS
24
+ @priority = Process::BELOW_NORMAL_PRIORITY_CLASS
36
25
  end
37
26
 
38
27
  test "win32-process version is set to the correct value" do
39
- assert_equal('0.6.6', Process::WIN32_PROCESS_VERSION)
40
- end
41
-
42
- test "kill basic functionality" do
43
- assert_respond_to(Process, :kill)
44
- end
45
-
46
- test "kill requires at least one argument" do
47
- assert_raises(ArgumentError){ Process.kill }
48
- end
49
-
50
- test "kill raises an error if an invalid signal is provided" do
51
- assert_raises(Process::Error){ Process.kill('SIGBOGUS') }
52
- end
53
-
54
- test "kill raises an error if an invalid process id is provided" do
55
- assert_raises(Process::Error){ Process.kill(0, 9999999) }
56
- end
57
-
58
- test "kill with signal 0 does not kill the process" do
59
- pid = @@pids.first
60
- assert_nothing_raised{ Process.kill(0, pid) }
61
- assert_not_nil(Sys::ProcTable.ps(pid))
62
- end
63
-
64
- test "kill with signal 1 kills the process normally" do
65
- pid = @@pids.shift
66
- assert_nothing_raised{ Process.kill(1, pid) }
67
- assert_nil(Sys::ProcTable.ps(pid))
68
- end
69
-
70
- test "kill with signal 9 kills the process brutally" do
71
- pid = @@pids.pop
72
- msg = "Could not find pid #{pid}"
73
- assert_nothing_raised(msg){ Process.kill(9, pid) }
74
- assert_nil(Sys::ProcTable.ps(pid))
75
- end
76
-
77
- test "fork basic functionality" do
78
- assert_respond_to(Process, :fork)
28
+ assert_equal('0.7.0', Process::WIN32_PROCESS_VERSION)
79
29
  end
80
30
 
81
31
  test "create basic functionality" do
@@ -93,7 +43,7 @@ class TC_Win32Process < Test::Unit::TestCase
93
43
  ).process_id
94
44
  }
95
45
 
96
- assert_nothing_raised{ Process.kill(1, @@pids.pop) }
46
+ assert_nothing_raised{ Process.kill(9, @@pids.pop) }
97
47
  end
98
48
 
99
49
  test "create requires a hash argument" do
@@ -117,36 +67,96 @@ class TC_Win32Process < Test::Unit::TestCase
117
67
  end
118
68
 
119
69
  test "create raises an error if the executable cannot be found" do
120
- err = "CreateProcess() failed: The system cannot find the file specified."
121
- assert_raise(Process::Error){ Process.create(:app_name => "bogusapp.exe") }
122
- assert_raise_message(err){ Process.create(:app_name => "bogusapp.exe") }
70
+ assert_raise(Errno::ENOENT){ Process.create(:app_name => "bogusapp.exe") }
123
71
  end
124
72
 
125
- test "wait basic functionality" do
126
- assert_respond_to(Process, :wait)
73
+ test "create passes local environment when environment is not specified" do
74
+ omit_if(@@jruby)
75
+ stdout_read, stdout_write = IO.pipe
76
+
77
+ ENV['AARDVARK'] = 'B'
78
+ assert_nothing_raised {
79
+ Process.create(
80
+ :app_name => 'cmd.exe /c echo %AARDVARK%',
81
+ :creation_flags => Process::DETACHED_PROCESS,
82
+ :startup_info => { :stdout => stdout_write }
83
+ )
84
+ }
85
+
86
+ stdout_write.close
87
+ assert_equal('B', stdout_read.read.chomp)
127
88
  end
128
89
 
129
- test "wait2 basic functionality" do
130
- assert_respond_to(Process, :wait2)
90
+ test "create does not pass local environment when environment is specified" do
91
+ omit_if(@@jruby)
92
+ stdout_read, stdout_write = IO.pipe
93
+
94
+ ENV['AARDVARK'] = 'B'
95
+ assert_nothing_raised {
96
+ Process.create(
97
+ :app_name => 'cmd.exe /c echo %AARDVARK%',
98
+ :creation_flags => Process::DETACHED_PROCESS,
99
+ :environment => "",
100
+ :startup_info => { :stdout => stdout_write }
101
+ )
102
+ }
103
+
104
+ stdout_write.close
105
+ assert_equal('%AARDVARK%', stdout_read.read.chomp)
131
106
  end
132
107
 
133
- test "waitpid basic functionality" do
134
- assert_respond_to(Process, :waitpid)
108
+ test "create supports :environment as a string" do
109
+ omit_if(@@jruby)
110
+ stdout_read, stdout_write = IO.pipe
111
+
112
+ assert_nothing_raised {
113
+ Process.create(
114
+ :app_name => 'cmd.exe /c echo %A% %C%',
115
+ :creation_flags => Process::DETACHED_PROCESS,
116
+ :environment => "A=B;C=D",
117
+ :startup_info => { :stdout => stdout_write }
118
+ )
119
+ }
120
+
121
+ stdout_write.close
122
+ assert_equal("B D", stdout_read.read.chomp)
135
123
  end
136
124
 
137
- test "waitpid2 basic functionality" do
138
- assert_respond_to(Process, :waitpid2)
125
+ test "create supports :environment as an array" do
126
+ omit_if(@@jruby)
127
+ stdout_read, stdout_write = IO.pipe
128
+
129
+ assert_nothing_raised {
130
+ Process.create(
131
+ :app_name => 'cmd.exe /c echo %A% %C%',
132
+ :creation_flags => Process::DETACHED_PROCESS,
133
+ :environment => [ "A=B;X;", "C=;D;Y" ],
134
+ :startup_info => { :stdout => stdout_write }
135
+ )
136
+ }
137
+
138
+ stdout_write.close
139
+ assert_equal("B;X; ;D;Y", stdout_read.read.chomp)
139
140
  end
140
141
 
141
- test "ppid basic functionality" do
142
- assert_respond_to(Process, :ppid)
143
- assert_nothing_raised{ Process.ppid }
142
+ test "create supports empty :environment string" do
143
+ assert_nothing_raised {
144
+ Process.create(
145
+ :creation_flags => Process::DETACHED_PROCESS,
146
+ :app_name => 'cmd.exe',
147
+ :environment => ''
148
+ )
149
+ }
144
150
  end
145
151
 
146
- test "ppid returns expected results" do
147
- assert_kind_of(Integer, Process.ppid)
148
- assert_true(Process.ppid > 0)
149
- assert_false(Process.pid == Process.ppid)
152
+ test "create supports empty :environment array" do
153
+ assert_nothing_raised {
154
+ Process.create(
155
+ :creation_flags => Process::DETACHED_PROCESS,
156
+ :app_name => 'cmd.exe',
157
+ :environment => []
158
+ )
159
+ }
150
160
  end
151
161
 
152
162
  test "uid basic functionality" do
@@ -193,15 +203,16 @@ class TC_Win32Process < Test::Unit::TestCase
193
203
 
194
204
  test "setpriority basic functionality" do
195
205
  assert_respond_to(Process, :setpriority)
196
- assert_nothing_raised{ Process.setpriority(0, Process.pid, @pri_class) }
206
+ assert_nothing_raised{ Process.setpriority(0, Process.pid, @priority) }
207
+ assert_equal(@priority, Process.getpriority(0, Process.pid))
197
208
  end
198
209
 
199
210
  test "setpriority returns zero on success" do
200
- assert_equal(0, Process.setpriority(0, Process.pid, @pri_class))
211
+ assert_equal(0, Process.setpriority(0, Process.pid, @priority))
201
212
  end
202
213
 
203
214
  test "setpriority treats an int argument of zero as the current process" do
204
- assert_equal(0, Process.setpriority(0, 0, @pri_class))
215
+ assert_equal(0, Process.setpriority(0, 0, @priority))
205
216
  end
206
217
 
207
218
  test "setpriority requires at least three arguments" do
@@ -211,8 +222,8 @@ class TC_Win32Process < Test::Unit::TestCase
211
222
  end
212
223
 
213
224
  test "arguments to setpriority must be numeric" do
214
- assert_raise(TypeError){ Process.setpriority('test', 0, @pri_class) }
215
- assert_raise(TypeError){ Process.setpriority(0, 'test', @pri_class) }
225
+ assert_raise(TypeError){ Process.setpriority('test', 0, @priority) }
226
+ assert_raise(TypeError){ Process.setpriority(0, 'test', @priority) }
216
227
  assert_raise(TypeError){ Process.setpriority(0, 0, 'test') }
217
228
  end
218
229
 
@@ -233,6 +244,7 @@ class TC_Win32Process < Test::Unit::TestCase
233
244
  test "getrlimit basic functionality" do
234
245
  assert_respond_to(Process, :getrlimit)
235
246
  assert_nothing_raised{ Process.getrlimit(Process::RLIMIT_CPU) }
247
+ assert_nothing_raised{ Process.getrlimit(Process::RLIMIT_FSIZE) }
236
248
  end
237
249
 
238
250
  test "getrlimit returns an array of two numeric elements" do
@@ -248,25 +260,25 @@ class TC_Win32Process < Test::Unit::TestCase
248
260
  end
249
261
 
250
262
  test "getrlimit requires a valid resource value" do
251
- assert_raise(Process::Error){ Process.getrlimit(9999) }
263
+ assert_raise(ArgumentError){ Process.getrlimit(9999) }
252
264
  end
253
265
 
254
266
  test "setrlimit basic functionality" do
255
- assert_respond_to(Process, :getrlimit)
256
- assert_nothing_raised{ Process.setrlimit(Process::RLIMIT_VMEM, 1024 * 4) }
267
+ assert_respond_to(Process, :setrlimit)
268
+ assert_nothing_raised{ Process.setrlimit(Process::RLIMIT_CPU, 1000000) }
257
269
  end
258
270
 
259
271
  test "setrlimit returns nil on success" do
260
- assert_nil(Process.setrlimit(Process::RLIMIT_VMEM, 1024 * 4))
272
+ assert_nil(Process.setrlimit(Process::RLIMIT_CPU, 1000000))
261
273
  end
262
274
 
263
275
  test "setrlimit sets the resource limit as expected" do
264
- assert_nothing_raised{ Process.setrlimit(Process::RLIMIT_VMEM, 1024 * 4) }
265
- assert_equal([4096, 4096], Process.getrlimit(Process::RLIMIT_VMEM))
276
+ assert_nothing_raised{ Process.setrlimit(Process::RLIMIT_CPU, 1000000) }
277
+ assert_equal([1000000, 1000000], Process.getrlimit(Process::RLIMIT_CPU))
266
278
  end
267
279
 
268
280
  test "setrlimit raises an error if the resource value is invalid" do
269
- assert_raise(Process::Error){ Process.setrlimit(9999, 100) }
281
+ assert_raise(ArgumentError){ Process.setrlimit(9999, 100) }
270
282
  end
271
283
 
272
284
  test "is_job basic functionality" do
@@ -282,12 +294,26 @@ class TC_Win32Process < Test::Unit::TestCase
282
294
  assert_raise(ArgumentError){ Process.job?(Process.pid) }
283
295
  end
284
296
 
297
+ test "volume_type is a private method" do
298
+ assert_not_respond_to(Process, :volume_type)
299
+ end
300
+
301
+ test "ffi functions are private" do
302
+ assert_not_respond_to(Process, :CloseHandle)
303
+ assert_not_respond_to(Process, :GetCurrentProcess)
304
+ assert_not_respond_to(Process, :GetProcessAffinityMask)
305
+ assert_not_respond_to(Process, :GetPriorityClass)
306
+ assert_not_respond_to(Process, :IsProcessInJob)
307
+ assert_not_respond_to(Process, :OpenProcess)
308
+ assert_not_respond_to(Process, :SetHandleInformation)
309
+ assert_not_respond_to(Process, :SetPriorityClass)
310
+ end
311
+
285
312
  def teardown
286
- @pri_class = nil
313
+ @priority = nil
287
314
  end
288
315
 
289
316
  def self.shutdown
290
- @@pids.each{ |pid| Process.kill(1, pid) }
291
- @@pids = []
317
+ @@pids = nil
292
318
  end
293
319
  end
@@ -0,0 +1,144 @@
1
+ ########################################################################
2
+ # test_win32_process_kill.rb
3
+ #
4
+ # Tests for the custom Process.kill method
5
+ ########################################################################
6
+ require 'win32/process'
7
+ require 'test-unit'
8
+
9
+ class TC_Win32_Process_Kill < Test::Unit::TestCase
10
+ def self.startup
11
+ @@signals = Signal.list
12
+ end
13
+
14
+ def setup
15
+ @ruby = RUBY_PLATFORM == 'java' ? 'jruby' : 'ruby'
16
+ @cmd = "#{@ruby} -e 'sleep 10'"
17
+ @pid = nil
18
+ end
19
+
20
+ test "kill basic functionality" do
21
+ assert_respond_to(Process, :kill)
22
+ end
23
+
24
+ test "kill with signal 0 does not actually send a signal" do
25
+ assert_nothing_raised{ Process.kill(0, Process.pid) }
26
+ end
27
+
28
+ test "kill with signal 0 returns 1 if the process exists" do
29
+ assert_equal(1, Process.kill(0, Process.pid))
30
+ end
31
+
32
+ test "kill with signal 0 raises an ESRCH error if any process does not exist" do
33
+ assert_raise(Errno::ESRCH){ Process.kill(0, 99999999) }
34
+ assert_raise(Errno::ESRCH){ Process.kill(0, Process.pid, 99999999) }
35
+ end
36
+
37
+ test "kill accepts multiple pid values" do
38
+ pid = Process.pid
39
+ assert_nothing_raised{ Process.kill(0, pid, pid, pid, pid) }
40
+ end
41
+
42
+ test "kill with any signal returns the number of killed processes" do
43
+ pid1 = Process.spawn(@cmd)
44
+ pid2 = Process.spawn(@cmd)
45
+ assert_equal(2, Process.kill(9, pid1, pid2))
46
+ end
47
+
48
+ test "kill accepts a string as a signal name" do
49
+ pid = Process.spawn(@cmd)
50
+ assert_nothing_raised{ Process.kill('SIGKILL', pid) }
51
+ end
52
+
53
+ test "kill accepts a string without 'SIG' as a signal name" do
54
+ pid = Process.spawn(@cmd)
55
+ assert_nothing_raised{ Process.kill('KILL', pid) }
56
+ end
57
+
58
+ test "kill accepts a symbol as a signal name" do
59
+ pid = Process.spawn(@cmd)
60
+ assert_nothing_raised{ Process.kill(:KILL, pid) }
61
+ end
62
+
63
+ test "kill coerces the pid to an integer" do
64
+ pid = Process.pid.to_f + 0.7
65
+ assert_nothing_raised{ Process.kill(0, pid) }
66
+ end
67
+
68
+ test "an EINVAL error is raised on Windows if the signal is negative" do
69
+ @pid = Process.spawn(@cmd)
70
+ assert_raise(Errno::EINVAL){ Process.kill(-3, @pid) }
71
+ end
72
+
73
+ test "an EINVAL error is raised on Windows if the pid is 0 and it's not a SIGINT" do
74
+ assert_raise(Errno::EINVAL){ Process.kill(9, 0) }
75
+ end
76
+
77
+ # We break from the spec here.
78
+ #test "an EINVAL error is raised if the pid is the current process and it's not a 0 or SIGKILL" do
79
+ # assert_raise(Errno::EINVAL){ Process.kill(1, Process.pid) }
80
+ #end
81
+
82
+ test "kill requires at least two arguments" do
83
+ assert_raise(ArgumentError){ Process.kill }
84
+ assert_raise(ArgumentError){ Process.kill(@pid) }
85
+ end
86
+
87
+ test "the first argument to kill must be an integer or string" do
88
+ assert_raise(ArgumentError){ Process.kill([], 0) }
89
+ end
90
+
91
+ test "kill raises an ArgumentError if the signal name is invalid" do
92
+ assert_raise(ArgumentError){ Process.kill("BOGUS", 0) }
93
+ end
94
+
95
+ test "kill does not accept lowercase signal names" do
96
+ assert_raise(ArgumentError){ Process.kill("kill", 0) }
97
+ end
98
+
99
+ test "kill raises an EINVAL error if the signal number is invalid" do
100
+ assert_raise(Errno::EINVAL){ Process.kill(999999, 0) }
101
+ end
102
+
103
+ test "kill raises an TypeError if the pid value is not an integer" do
104
+ assert_raise(TypeError){ Process.kill(0, "BOGUS") }
105
+ end
106
+
107
+ # TODO: Fix this
108
+ #test "kill raises an EPERM if user does not have proper privileges" do
109
+ # omit_if(Process.uid == 0)
110
+ # assert_raise(Errno::EPERM){ Process.kill(9, 1) }
111
+ #end
112
+
113
+ test "kill raises a SecurityError if $SAFE level is 2 or greater" do
114
+ omit_if(@ruby == 'jruby')
115
+ assert_raise(SecurityError){
116
+ proc do
117
+ $SAFE = 2
118
+ @pid = Process.spawn(@cmd)
119
+ Process.kill(9, @pid)
120
+ end.call
121
+ }
122
+ end
123
+
124
+ test "kill works if the $SAFE level is 1 or lower" do
125
+ omit_if(@ruby == 'jruby')
126
+ assert_nothing_raised{
127
+ proc do
128
+ $SAFE = 1
129
+ @pid = Process.spawn(@cmd)
130
+ Process.kill(9, @pid)
131
+ end.call
132
+ }
133
+ end
134
+
135
+ def teardown
136
+ @cmd = nil
137
+ @ruby = nil
138
+ Process.kill(9, @pid) if @pid rescue nil
139
+ end
140
+
141
+ def self.teardown
142
+ @@signals = nil
143
+ end
144
+ end
@@ -2,12 +2,11 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'win32-process'
5
- spec.version = '0.6.6'
5
+ spec.version = '0.7.0'
6
6
  spec.license = 'Artistic 2.0'
7
7
  spec.authors = ['Daniel Berger', 'Park Heesob']
8
8
  spec.email = 'djberg96@gmail.com'
9
- spec.homepage = 'http://www.rubyforge.org/projects/win32utils'
10
- spec.platform = Gem::Platform::RUBY
9
+ spec.homepage = 'https://github.com/djberg96/win32-process'
11
10
  spec.summary = 'Adds and redefines several Process methods for MS Windows'
12
11
  spec.test_files = Dir['test/*.rb']
13
12
  spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
@@ -15,14 +14,14 @@ Gem::Specification.new do |spec|
15
14
  spec.rubyforge_project = 'win32utils'
16
15
  spec.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
17
16
 
18
- spec.add_dependency('windows-pr', '>= 1.2.2')
19
- spec.add_development_dependency('test-unit')
20
- spec.add_development_dependency('sys-proctable')
17
+ spec.required_ruby_version = '> 1.9.0'
18
+ spec.add_dependency('ffi', '>= 1.0.0')
19
+ spec.add_development_dependency('test-unit', '>= 2.4.0')
21
20
 
22
21
  spec.description = <<-EOF
23
22
  The win32-process library implements several Process methods that are
24
23
  either unimplemented or dysfunctional in some way in the default Ruby
25
- implementation. Examples include Process.kill, Process.waitpid,
26
- Process.create and an experimental Process.fork method.
24
+ implementation. Examples include Process.kill, Process.uid and
25
+ Process.create.
27
26
  EOF
28
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: win32-process
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.6
4
+ version: 0.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,16 +10,16 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-07-19 00:00:00.000000000 Z
13
+ date: 2012-08-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: windows-pr
16
+ name: ffi
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
21
21
  - !ruby/object:Gem::Version
22
- version: 1.2.2
22
+ version: 1.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,7 +27,7 @@ dependencies:
27
27
  requirements:
28
28
  - - ! '>='
29
29
  - !ruby/object:Gem::Version
30
- version: 1.2.2
30
+ version: 1.0.0
31
31
  - !ruby/object:Gem::Dependency
32
32
  name: test-unit
33
33
  requirement: !ruby/object:Gem::Requirement
@@ -35,7 +35,7 @@ dependencies:
35
35
  requirements:
36
36
  - - ! '>='
37
37
  - !ruby/object:Gem::Version
38
- version: '0'
38
+ version: 2.4.0
39
39
  type: :development
40
40
  prerelease: false
41
41
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,27 +43,10 @@ dependencies:
43
43
  requirements:
44
44
  - - ! '>='
45
45
  - !ruby/object:Gem::Version
46
- version: '0'
47
- - !ruby/object:Gem::Dependency
48
- name: sys-proctable
49
- requirement: !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- type: :development
56
- prerelease: false
57
- version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
- requirements:
60
- - - ! '>='
61
- - !ruby/object:Gem::Version
62
- version: '0'
46
+ version: 2.4.0
63
47
  description: ! " The win32-process library implements several Process methods that
64
48
  are\n either unimplemented or dysfunctional in some way in the default Ruby\n
65
- \ implementation. Examples include Process.kill, Process.waitpid,\n Process.create
66
- and an experimental Process.fork method.\n"
49
+ \ implementation. Examples include Process.kill, Process.uid and\n Process.create.\n"
67
50
  email: djberg96@gmail.com
68
51
  executables: []
69
52
  extensions: []
@@ -74,16 +57,19 @@ extra_rdoc_files:
74
57
  files:
75
58
  - CHANGES
76
59
  - examples/example_create.rb
77
- - examples/example_fork_wait.rb
78
- - examples/example_fork_waitpid.rb
79
60
  - examples/example_kill.rb
61
+ - lib/win32/process/constants.rb
62
+ - lib/win32/process/functions.rb
63
+ - lib/win32/process/helper.rb
64
+ - lib/win32/process/structs.rb
80
65
  - lib/win32/process.rb
81
66
  - MANIFEST
82
67
  - Rakefile
83
68
  - README
84
69
  - test/test_win32_process.rb
70
+ - test/test_win32_process_kill.rb
85
71
  - win32-process.gemspec
86
- homepage: http://www.rubyforge.org/projects/win32utils
72
+ homepage: https://github.com/djberg96/win32-process
87
73
  licenses:
88
74
  - Artistic 2.0
89
75
  post_install_message:
@@ -93,9 +79,9 @@ require_paths:
93
79
  required_ruby_version: !ruby/object:Gem::Requirement
94
80
  none: false
95
81
  requirements:
96
- - - ! '>='
82
+ - - ! '>'
97
83
  - !ruby/object:Gem::Version
98
- version: '0'
84
+ version: 1.9.0
99
85
  required_rubygems_version: !ruby/object:Gem::Requirement
100
86
  none: false
101
87
  requirements:
@@ -110,3 +96,4 @@ specification_version: 3
110
96
  summary: Adds and redefines several Process methods for MS Windows
111
97
  test_files:
112
98
  - test/test_win32_process.rb
99
+ - test/test_win32_process_kill.rb
@@ -1,29 +0,0 @@
1
- ##########################################################################
2
- # example_fork_wait.rb
3
- #
4
- # Generic test script for futzing around with the block form of
5
- # fork/wait. You can run this example via the 'example:fork_wait' task.
6
- ##########################################################################
7
- require 'win32/process'
8
-
9
- puts "VERSION: " + Process::WIN32_PROCESS_VERSION
10
-
11
- # In the child, using block form
12
- fork{
13
- 7.times { |i|
14
- puts "Child: #{i}"
15
- sleep 1
16
- }
17
- }
18
-
19
- # Back in the parent
20
- 4.times{ |i|
21
- puts "Parent: #{i}"
22
- sleep 1
23
- }
24
-
25
- # Wait for the children
26
- Process.wait
27
-
28
- # Children should be done here before continuing on
29
- puts "Continuing on..."
@@ -1,46 +0,0 @@
1
- ##########################################################################
2
- # example_fork_waitpid.rb
3
- #
4
- # Generic test script for futzing around with the traditional form of
5
- # fork/wait, plus waitpid and waitpid2.
6
- #
7
- # You can run this code via the 'example:fork_waitpid' task.
8
- ##########################################################################
9
- require 'win32/process'
10
-
11
- puts "VERSION: " + Process::WIN32_PROCESS_VERSION
12
-
13
- pid = Process.fork
14
- puts "PID1: #{pid}"
15
-
16
- #child
17
- if pid.nil?
18
- 7.times{ |i|
19
- puts "Child: #{i}"
20
- sleep 1
21
- }
22
- exit(-1)
23
- end
24
-
25
- pid2 = Process.fork
26
- puts "PID2: #{pid2}"
27
-
28
- #child2
29
- if pid2.nil?
30
- 7.times{ |i|
31
- puts "Child2: #{i}"
32
- sleep 1
33
- }
34
- exit(1)
35
- end
36
-
37
- #parent
38
- 2.times { |i|
39
- puts "Parent: #{i}"
40
- sleep 1
41
- }
42
-
43
- p Process.waitpid2(pid)
44
- p Process.waitpid2(pid2)
45
-
46
- puts "Continuing on..."