win32-process 0.8.3 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,165 +1,143 @@
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
- test "kill accepts BRK or SIGBRK as a signal name" do
78
- pid = Process.spawn(@cmd)
79
- assert_nothing_raised{ Process.kill(:BRK, pid) }
80
- assert_nothing_raised{ Process.kill(:SIGBRK, pid) }
81
- end
82
-
83
- # We break from the spec here.
84
- #test "an EINVAL error is raised if the pid is the current process and it's not a 0 or SIGKILL" do
85
- # assert_raise(Errno::EINVAL){ Process.kill(1, Process.pid) }
86
- #end
87
-
88
- test "kill requires at least two arguments" do
89
- assert_raise(ArgumentError){ Process.kill }
90
- assert_raise(ArgumentError){ Process.kill(@pid) }
91
- end
92
-
93
- test "the first argument to kill must be an integer or string" do
94
- assert_raise(ArgumentError){ Process.kill([], 0) }
95
- end
96
-
97
- test "kill raises an ArgumentError if the signal name is invalid" do
98
- assert_raise(ArgumentError){ Process.kill("BOGUS", 0) }
99
- end
100
-
101
- test "kill does not accept lowercase signal names" do
102
- assert_raise(ArgumentError){ Process.kill("kill", 0) }
103
- end
104
-
105
- test "kill raises an EINVAL error if the signal number is invalid" do
106
- assert_raise(Errno::EINVAL){ Process.kill(999999, 0) }
107
- end
108
-
109
- test "kill raises an TypeError if the pid value is not an integer" do
110
- assert_raise(TypeError){ Process.kill(0, "BOGUS") }
111
- end
112
-
113
- # TODO: Fix this
114
- #test "kill raises an EPERM if user does not have proper privileges" do
115
- # omit_if(Process.uid == 0)
116
- # assert_raise(Errno::EPERM){ Process.kill(9, 1) }
117
- #end
118
-
119
- test "kill raises a SecurityError if $SAFE level is 2 or greater" do
120
- omit_if(@ruby == 'jruby')
121
- assert_raise(SecurityError){
122
- proc do
123
- $SAFE = 2
124
- @pid = Process.spawn(@cmd)
125
- Process.kill(9, @pid)
126
- end.call
127
- }
128
- end
129
-
130
- test "kill works if the $SAFE level is 1 or lower" do
131
- omit_if(@ruby == 'jruby')
132
- assert_nothing_raised{
133
- proc do
134
- $SAFE = 1
135
- @pid = Process.spawn(@cmd)
136
- Process.kill(9, @pid)
137
- end.call
138
- }
139
- end
140
-
141
- =begin
142
- test "kill(0) can't tell if the process ended, use get_exitcode instead" do
143
- pid = Process.create(
144
- :app_name => 'cmd /c exit 0',
145
- :creation_flags => Process::DETACHED_PROCESS
146
- ).process_id
147
- 10.times do
148
- sleep(0.1)
149
- assert_nothing_raised do
150
- assert_equal 1, Process.kill(0, pid)
151
- end
152
- end
153
- end
154
- =end
155
-
156
- def teardown
157
- @cmd = nil
158
- @ruby = nil
159
- Process.kill(9, @pid) if @pid rescue nil
160
- end
161
-
162
- def self.teardown
163
- @@signals = nil
164
- end
165
- end
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
+ test "kill accepts BRK or SIGBRK as a signal name" do
78
+ pid = Process.spawn(@cmd)
79
+ assert_nothing_raised{ Process.kill(:BRK, pid) }
80
+ assert_nothing_raised{ Process.kill(:SIGBRK, pid) }
81
+ end
82
+
83
+ # We break from the spec here.
84
+ #test "an EINVAL error is raised if the pid is the current process and it's not a 0 or SIGKILL" do
85
+ # assert_raise(Errno::EINVAL){ Process.kill(1, Process.pid) }
86
+ #end
87
+
88
+ test "kill requires at least two arguments" do
89
+ assert_raise(ArgumentError){ Process.kill }
90
+ assert_raise(ArgumentError){ Process.kill(@pid) }
91
+ end
92
+
93
+ test "the first argument to kill must be an integer or string" do
94
+ assert_raise(ArgumentError){ Process.kill([], 0) }
95
+ end
96
+
97
+ test "kill raises an ArgumentError if the signal name is invalid" do
98
+ assert_raise(ArgumentError){ Process.kill("BOGUS", 0) }
99
+ end
100
+
101
+ test "kill does not accept lowercase signal names" do
102
+ assert_raise(ArgumentError){ Process.kill("kill", 0) }
103
+ end
104
+
105
+ test "kill raises an EINVAL error if the signal number is invalid" do
106
+ assert_raise(Errno::EINVAL){ Process.kill(999999, 0) }
107
+ end
108
+
109
+ test "kill raises an TypeError if the pid value is not an integer" do
110
+ assert_raise(TypeError){ Process.kill(0, "BOGUS") }
111
+ end
112
+
113
+ # TODO: Fix this
114
+ #test "kill raises an EPERM if user does not have proper privileges" do
115
+ # omit_if(Process.uid == 0)
116
+ # assert_raise(Errno::EPERM){ Process.kill(9, 1) }
117
+ #end
118
+
119
+ =begin
120
+ test "kill(0) can't tell if the process ended, use get_exitcode instead" do
121
+ pid = Process.create(
122
+ :app_name => 'cmd /c exit 0',
123
+ :creation_flags => Process::DETACHED_PROCESS
124
+ ).process_id
125
+ 10.times do
126
+ sleep(0.1)
127
+ assert_nothing_raised do
128
+ assert_equal 1, Process.kill(0, pid)
129
+ end
130
+ end
131
+ end
132
+ =end
133
+
134
+ def teardown
135
+ @cmd = nil
136
+ @ruby = nil
137
+ Process.kill(9, @pid) if @pid rescue nil
138
+ end
139
+
140
+ def self.teardown
141
+ @@signals = nil
142
+ end
143
+ end
@@ -1,29 +1,23 @@
1
- require 'rubygems'
2
-
3
- Gem::Specification.new do |spec|
4
- spec.name = 'win32-process'
5
- spec.version = '0.8.3'
6
- spec.license = 'Artistic 2.0'
7
- spec.authors = ['Daniel Berger', 'Park Heesob']
8
- spec.email = 'djberg96@gmail.com'
9
- spec.homepage = 'https://github.com/djberg96/win32-process'
10
- spec.summary = 'Adds and redefines several Process methods for MS Windows'
11
- spec.test_files = Dir['test/*.rb']
12
- spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
13
- spec.cert_chain = Dir['certs/*']
14
-
15
- spec.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
16
-
17
- spec.required_ruby_version = '> 1.9.0'
18
- spec.add_dependency('ffi', '>= 1.0.0')
19
-
20
- spec.add_development_dependency('rake')
21
- spec.add_development_dependency('test-unit', '>= 2.4.0')
22
-
23
- spec.description = <<-EOF
24
- The win32-process library implements several Process methods that are
25
- either unimplemented or dysfunctional in some way in the default Ruby
26
- implementation. Examples include Process.kill, Process.uid and
27
- Process.create.
28
- EOF
29
- end
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "win32-process"
3
+ spec.version = "0.9.0"
4
+ spec.license = "Artistic-2.0"
5
+ spec.authors = ["Daniel Berger", "Park Heesob"]
6
+ spec.email = "djberg96@gmail.com"
7
+ spec.homepage = "https://github.com/chef/win32-process"
8
+ spec.summary = "Adds and redefines several Process methods for Microsoft Windows"
9
+ spec.test_files = Dir["test/*.rb"]
10
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(/^(\..*|Gemfile|Rakefile|examples|test|CHANGELOG.md)/) }
11
+
12
+ spec.extra_rdoc_files = ["README.md"]
13
+
14
+ spec.required_ruby_version = "> 1.9.0"
15
+ spec.add_dependency("ffi", ">= 1.0.0")
16
+
17
+ spec.description = <<-EOF
18
+ The win32-process library implements several Process methods that are
19
+ either unimplemented or dysfunctional in some way in the default Ruby
20
+ implementation. Examples include Process.kill, Process.uid and
21
+ Process.create.
22
+ EOF
23
+ end
metadata CHANGED
@@ -1,37 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: win32-process
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Berger
8
8
  - Park Heesob
9
9
  autorequire:
10
10
  bindir: bin
11
- cert_chain:
12
- - |
13
- -----BEGIN CERTIFICATE-----
14
- MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MREwDwYDVQQDDAhkamJl
15
- cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
16
- MB4XDTE1MDkwMjIwNDkxOFoXDTE2MDkwMTIwNDkxOFowPzERMA8GA1UEAwwIZGpi
17
- ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
18
- bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMyTkvXqRp6hLs9eoJOS
19
- Hmi8kRYbq9Vkf15/hMxJpotYMgJVHHWrmDcC5Dye2PbnXjTkKf266Zw0PtT9h+lI
20
- S3ts9HO+vaCFSMwFFZmnWJSpQ3CNw2RcHxjWkk9yF7imEM8Kz9ojhiDXzBetdV6M
21
- gr0lV/alUr7TNVBDngbXEfTWscyXh1qd7xZ4EcOdsDktCe5G45N/o3662tPQvJsi
22
- FOF0CM/KuBsa/HL1/eoEmF4B3EKIRfTHrQ3hu20Kv3RJ88QM4ec2+0dd97uX693O
23
- zv6981fyEg+aXLkxrkViM/tz2qR2ZE0jPhHTREPYeMEgptRkTmWSKAuLVWrJEfgl
24
- DtkCAwEAAaN3MHUwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFEwe
25
- nn6bfJADmuIDiMSOzedOrL+xMB0GA1UdEQQWMBSBEmRqYmVyZzk2QGdtYWlsLmNv
26
- bTAdBgNVHRIEFjAUgRJkamJlcmc5NkBnbWFpbC5jb20wDQYJKoZIhvcNAQEFBQAD
27
- ggEBAHmNOCWoDVD75zHFueY0viwGDVP1BNGFC+yXcb7u2GlK+nEMCORqzURbYPf7
28
- tL+/hzmePIRz7i30UM//64GI1NLv9jl7nIwjhPpXpf7/lu2I9hOTsvwSumb5UiKC
29
- /sqBxI3sfj9pr79Wpv4MuikX1XPik7Ncb7NPsJPw06Lvyc3Hkg5X2XpPtLtS+Gr2
30
- wKJnmzb5rIPS1cmsqv0M9LPWflzfwoZ/SpnmhagP+g05p8bRNKjZSA2iImM/GyYZ
31
- EJYzxdPOrx2n6NYR3Hk+vHP0U7UBSveI6+qx+ndQYaeyCn+GRX2PKS9h66YF/Q1V
32
- tGSHgAmcLlkdGgan182qsE/4kKM=
33
- -----END CERTIFICATE-----
34
- date: 2015-12-16 00:00:00.000000000 Z
11
+ cert_chain: []
12
+ date: 2020-10-29 00:00:00.000000000 Z
35
13
  dependencies:
36
14
  - !ruby/object:Gem::Dependency
37
15
  name: ffi
@@ -47,34 +25,6 @@ dependencies:
47
25
  - - ">="
48
26
  - !ruby/object:Gem::Version
49
27
  version: 1.0.0
50
- - !ruby/object:Gem::Dependency
51
- name: rake
52
- requirement: !ruby/object:Gem::Requirement
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: '0'
57
- type: :development
58
- prerelease: false
59
- version_requirements: !ruby/object:Gem::Requirement
60
- requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- version: '0'
64
- - !ruby/object:Gem::Dependency
65
- name: test-unit
66
- requirement: !ruby/object:Gem::Requirement
67
- requirements:
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- version: 2.4.0
71
- type: :development
72
- prerelease: false
73
- version_requirements: !ruby/object:Gem::Requirement
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- version: 2.4.0
78
28
  description: |2
79
29
  The win32-process library implements several Process methods that are
80
30
  either unimplemented or dysfunctional in some way in the default Ruby
@@ -84,35 +34,21 @@ email: djberg96@gmail.com
84
34
  executables: []
85
35
  extensions: []
86
36
  extra_rdoc_files:
87
- - README
88
- - CHANGES
89
- - MANIFEST
37
+ - README.md
90
38
  files:
91
- - certs
92
- - certs/djberg96_pub.pem
93
- - CHANGES
94
- - examples
95
- - examples/example_create.rb
96
- - examples/example_kill.rb
97
- - lib
98
- - lib/win32
99
- - lib/win32/process
39
+ - README.md
40
+ - lib/win32-process.rb
41
+ - lib/win32/process.rb
100
42
  - lib/win32/process/constants.rb
101
43
  - lib/win32/process/functions.rb
102
44
  - lib/win32/process/helper.rb
103
45
  - lib/win32/process/structs.rb
104
- - lib/win32/process.rb
105
- - lib/win32-process.rb
106
- - MANIFEST
107
- - Rakefile
108
- - README
109
- - test
110
46
  - test/test_win32_process.rb
111
47
  - test/test_win32_process_kill.rb
112
48
  - win32-process.gemspec
113
- homepage: https://github.com/djberg96/win32-process
49
+ homepage: https://github.com/chef/win32-process
114
50
  licenses:
115
- - Artistic 2.0
51
+ - Artistic-2.0
116
52
  metadata: {}
117
53
  post_install_message:
118
54
  rdoc_options: []
@@ -129,11 +65,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
65
  - !ruby/object:Gem::Version
130
66
  version: '0'
131
67
  requirements: []
132
- rubyforge_project:
133
- rubygems_version: 2.4.8
68
+ rubygems_version: 3.1.2
134
69
  signing_key:
135
70
  specification_version: 4
136
- summary: Adds and redefines several Process methods for MS Windows
71
+ summary: Adds and redefines several Process methods for Microsoft Windows
137
72
  test_files:
138
73
  - test/test_win32_process.rb
139
74
  - test/test_win32_process_kill.rb