proc-wait3 1.9.2 → 1.9.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6e56b25dc085ce18c5808a81d259c4e9f54cb75d1ff985985bb5a575d58ed90
4
- data.tar.gz: 65379d28529797369401cc65abb6c234b9cf1995ec7cf92152d03c03c6a89a83
3
+ metadata.gz: 13f18822c2208220d663b7ddf89cd3ef3763185621f23ed81bf6dced9beb8b76
4
+ data.tar.gz: 6a82d5550af63215cf4e62b3e390865f5f08e3b3ec30be50128791bf8b9a45a1
5
5
  SHA512:
6
- metadata.gz: 51f2d1148e8fcadb8b9530420ac164e81b4645b04e3f7b8acded43a62acaa3000240f5e5e53b5fda4cc734f0e2f76edbf76d5b325c2cc3fefd450cf0f60ca519
7
- data.tar.gz: ce1e71899e8db9c2c74bb5207d3a715e7cf8b355d0c5b6bc203b51608647d90fe53c0414bce48ee38c1c796987df7f9fa2b4a30c9eeebdd35900e34d288be82a
6
+ metadata.gz: b015e49e3c835d2855552e3d54f2fdf047d11889f5db55ac2db246d277c9fe3ad1135e73e6cb01a0caa5d88bd93c3de361670d74dc78b3a5139c10ea86db46c7
7
+ data.tar.gz: f0134f481fa6f8d3cdbdcef1e6f380727afb894e1ed754bd77b568f3a0d43118a3c71aa93f68ea7d96b15768f569fa63199782f91c5c2d729c9efc47cdb0d0ab
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGES.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 1.9.3 - 4-May-2024
2
+ * Some internal refactoring where I bzero C structs before using them.
3
+
1
4
  ## 1.9.2 - 21-Apr-2024
2
5
  * Added the P_JAILID constant for BSD platforms.
3
6
  * Added some notes to the README for coping with EINTR.
data/ext/proc/wait3.c CHANGED
@@ -154,6 +154,7 @@ static VALUE proc_wait3(int argc, VALUE *argv, VALUE mod){
154
154
  flags = NUM2INT(v_flags);
155
155
  }
156
156
 
157
+ bzero(&r, sizeof(r));
157
158
  pid = wait3(&status, flags, &r);
158
159
 
159
160
  if(pid < 0){
@@ -226,6 +227,7 @@ static VALUE proc_wait4(int argc, VALUE *argv, VALUE mod){
226
227
  if(RTEST(v_flags))
227
228
  flags = NUM2INT(v_flags);
228
229
 
230
+ bzero(&r, sizeof(r));
229
231
  pid = wait4(pid, &status, flags, &r);
230
232
 
231
233
  if(pid < 0){
@@ -587,6 +589,9 @@ static VALUE proc_pause(int argc, VALUE* argv, VALUE mod){
587
589
  int signum;
588
590
  struct sigaction act, sa;
589
591
 
592
+ bzero(&act, sizeof(act));
593
+ bzero(&sa, sizeof(sa));
594
+
590
595
  for(i = 0; i < len; i++){
591
596
  v_val = rb_ary_shift(v_signals);
592
597
 
@@ -752,6 +757,8 @@ static VALUE proc_getrusage(int argc, VALUE* argv, VALUE mod){
752
757
  else if(RTEST(v_children))
753
758
  who = RUSAGE_CHILDREN;
754
759
 
760
+ bzero(&r, sizeof(r));
761
+
755
762
  if(getrusage(who,&r) == -1)
756
763
  rb_sys_fail("getrusage");
757
764
 
@@ -966,8 +973,8 @@ void Init_wait3(void)
966
973
  rb_define_const(rb_mProcess, "RUSAGE_THREAD", INT2FIX(RUSAGE_THREAD));
967
974
  #endif
968
975
 
969
- /* 1.9.2: The version of the proc-wait3 library */
970
- rb_define_const(rb_mProcess, "WAIT3_VERSION", rb_str_freeze(rb_str_new2("1.9.2")));
976
+ /* 1.9.3: The version of the proc-wait3 library */
977
+ rb_define_const(rb_mProcess, "WAIT3_VERSION", rb_str_freeze(rb_str_new2("1.9.3")));
971
978
 
972
979
  /* Define this last in our Init_wait3 function */
973
980
  rb_define_readonly_variable("$last_status", &v_last_status);
data/proc-wait3.gemspec CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'proc-wait3'
5
- spec.version = '1.9.2'
5
+ spec.version = '1.9.3'
6
6
  spec.author = 'Daniel J. Berger'
7
7
  spec.license = 'Apache-2.0'
8
8
  spec.email = 'djberg96@gmail.com'
@@ -1,26 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- #######################################################################
3
+ ##############################################################################
4
4
  # proc_wait3_spec.rb
5
5
  #
6
- # Test suite for the Ruby proc-wait3 library. You should run these
7
- # via the 'rake spec' task.
8
- #######################################################################
6
+ # Test suite for the Ruby proc-wait3 library. You should run these via the
7
+ # 'rake spec' task.
8
+ #
9
+ # Note that several specs are deliberately wrapped in EINTR rescue handlers
10
+ # because I think the Ruby interpreter is sending a signal to the process
11
+ # from somewhere in the guts of its core code. Originally I thought this was
12
+ # a SIGCHLD but it doesn't always appear to be.
13
+ ##############################################################################
9
14
  require 'English'
10
- require 'proc/wait3'
11
- require 'rspec'
15
+ require 'spec_helper'
12
16
  require 'rbconfig'
13
17
 
14
18
  RSpec.describe Process do
15
- # Something in the guts of Ruby was being a pain.
16
- Signal.trap('CHLD', 'IGNORE') if RUBY_VERSION.to_f < 3
17
-
18
- let(:solaris) { RbConfig::CONFIG['host_os'] =~ /sunos|solaris/i }
19
- let(:darwin) { RbConfig::CONFIG['host_os'] =~ /darwin|osx/i }
20
- let(:hpux) { RbConfig::CONFIG['host_os'] =~ /hpux/i }
21
- let(:linux) { RbConfig::CONFIG['host_os'] =~ /linux/i }
22
- let(:bsd) { RbConfig::CONFIG['host_os'] =~ /bsd|dragonfly/i }
23
-
24
19
  let(:proc_stat_members) {
25
20
  %i[
26
21
  pid status utime stime maxrss ixrss idrss isrss minflt majflt nswap
@@ -34,8 +29,26 @@ RSpec.describe Process do
34
29
  @pid = nil
35
30
  end
36
31
 
32
+ def call_wait3
33
+ described_class.wait3
34
+ rescue Errno::EINTR
35
+ retry
36
+ end
37
+
38
+ def call_wait4(*args)
39
+ described_class.wait4(*args)
40
+ rescue Errno::EINTR
41
+ retry
42
+ end
43
+
44
+ def call_waitid(*args)
45
+ described_class.waitid(*args)
46
+ rescue Errno::EINTR
47
+ retry
48
+ end
49
+
37
50
  example 'version constant is set to expected value' do
38
- expect(Process::WAIT3_VERSION).to eq('1.9.2')
51
+ expect(Process::WAIT3_VERSION).to eq('1.9.3')
39
52
  expect(Process::WAIT3_VERSION).to be_frozen
40
53
  end
41
54
 
@@ -44,15 +57,13 @@ RSpec.describe Process do
44
57
  end
45
58
 
46
59
  example 'wait3 works as expected' do
47
- skip 'wait3 test skipped on this platform' if darwin
48
60
  @pid = fork { sleep 0.5 }
49
- expect { described_class.wait3 }.not_to raise_error
61
+ expect { call_wait3 }.not_to raise_error
50
62
  end
51
63
 
52
64
  example 'wait3 returns the expected proc status members' do
53
- skip 'wait3 test skipped on this platform' if darwin
54
65
  @pid = fork { sleep 0.5 }
55
- expect { @proc_stat = described_class.wait3 }.not_to raise_error
66
+ expect { @proc_stat = call_wait3 }.not_to raise_error
56
67
  expect(@proc_stat.members).to eq(proc_stat_members)
57
68
  end
58
69
 
@@ -62,116 +73,89 @@ RSpec.describe Process do
62
73
  end
63
74
 
64
75
  example 'wait3 sets and returns $last_status to expected values' do
65
- skip 'wait3 test skipped on this platform' if darwin
66
76
  @pid = fork { sleep 0.5 }
67
- described_class.wait3
77
+ call_wait3
68
78
  expect($last_status).to be_a(Struct::ProcStat)
69
79
  expect($last_status).not_to be_nil
70
80
  end
71
81
 
72
82
  example 'wait3 sets pid and status members of $?' do
73
- skip 'wait3 test skipped on this platform' if darwin
74
83
  @pid = fork { sleep 0.5 }
75
- described_class.wait3
84
+ call_wait3
76
85
  expect($CHILD_STATUS).not_to be_nil
77
86
  end
78
87
 
79
88
  example 'wait3 returns frozen struct' do
80
- skip 'wait3 test skipped on this platform' if darwin
81
89
  @pid = fork { sleep 0.5 }
82
- struct = described_class.wait3
90
+ struct = call_wait3
83
91
  expect(struct).to be_frozen
84
92
  end
85
93
 
86
- example 'getdtablesize works as expected' do
87
- skip 'getdtablesize skipped on this platform' unless solaris
88
-
94
+ example 'getdtablesize works as expected', :solaris do
89
95
  expect(described_class).to respond_to(:getdtablesize)
90
96
  expect(described_class.getdtablesize).to be_a(Integer)
91
97
  assert(described_class.getdtablesize > 0)
92
98
  end
93
99
 
94
- example 'wait4 method is defined' do
95
- skip 'wait4 test skipped on this platform' if hpux
100
+ example 'wait4 method is defined', :skip_hpux do
96
101
  expect(described_class).to respond_to(:wait4)
97
102
  end
98
103
 
99
- example 'wait4 requires at least one argument' do
100
- skip 'wait4 test skipped on this platform' if hpux
101
- expect { described_class.wait4 }.to raise_error(ArgumentError)
104
+ example 'wait4 requires at least one argument', :skip_hpux do
105
+ expect { call_wait4 }.to raise_error(ArgumentError)
102
106
  end
103
107
 
104
- example 'wait4 works as expected' do
105
- skip 'wait4 test skipped on this platform' if hpux || darwin
106
-
108
+ example 'wait4 works as expected', :skip_hpux do
107
109
  @pid = fork { sleep 0.5 }
108
- expect { @proc_stat = described_class.wait4(@pid) }.not_to raise_error
110
+ expect { @proc_stat = call_wait4(@pid) }.not_to raise_error
109
111
  expect(@proc_stat).to be_a(Struct::ProcStat)
110
112
  end
111
113
 
112
- example 'wait4 sets and returns $last_status to expected values' do
113
- skip 'wait4 test skipped on this platform' if hpux || darwin
114
-
114
+ example 'wait4 sets and returns $last_status to expected values', :skip_hpux do
115
115
  @pid = fork { sleep 0.5 }
116
- described_class.wait4(@pid)
116
+ call_wait4(@pid)
117
117
  expect($last_status).to be_a(Struct::ProcStat)
118
118
  expect($last_status).not_to be_nil
119
119
  end
120
120
 
121
- example 'wait4 sets pid and status members of $?' do
122
- skip 'wait4 test skipped on this platform' if hpux || darwin
123
-
121
+ example 'wait4 sets pid and status members of $?', :skip_hpux do
124
122
  @pid = fork { sleep 0.5 }
125
- described_class.wait4(@pid)
123
+ call_wait4(@pid)
126
124
  expect($CHILD_STATUS).not_to be_nil
127
125
  end
128
126
 
129
- example 'wait4 returns frozen struct' do
130
- skip 'wait4 test skipped on this platform' if hpux || darwin
131
-
127
+ example 'wait4 returns frozen struct', :skip_hpux do
132
128
  @pid = fork { sleep 0.5 }
133
- struct = described_class.wait4(@pid)
129
+ struct = call_wait4(@pid)
134
130
  expect(struct).to be_frozen
135
131
  end
136
132
 
137
- example 'waitid method is defined' do
138
- skip 'waitid test skipped on this platform' if hpux || darwin || bsd
139
-
133
+ example 'waitid method is defined', :skip_hpux do
140
134
  expect(described_class).to respond_to(:waitid)
141
135
  end
142
136
 
143
- example 'waitid method works as expected' do
144
- skip 'waitid test skipped on this platform' if hpux || darwin || bsd
145
-
137
+ example 'waitid method works as expected', :skip_hpux do
146
138
  @pid = fork { sleep 0.5 }
147
- expect { described_class.waitid(Process::P_PID, @pid, Process::WEXITED) }.not_to raise_error
139
+ expect { call_waitid(Process::P_PID, @pid, Process::WEXITED) }.not_to raise_error
148
140
  end
149
141
 
150
- example 'waitid method raises expected errors if wrong argument type is passed' do
151
- skip 'waitid test skipped on this platform' if hpux || darwin || bsd
152
-
142
+ example 'waitid method raises expected errors if wrong argument type is passed', :skip_hpux do
153
143
  @pid = fork { sleep 0.5 }
154
- expect { described_class.waitid('foo', @pid, Process::WEXITED) }.to raise_error(TypeError)
155
- expect { described_class.waitid(Process::P_PID, @pid, 'foo') }.to raise_error(TypeError)
156
- expect { described_class.waitid(Process::P_PID, 'foo', Process::WEXITED) }.to raise_error(TypeError)
144
+ expect { call_waitid('foo', @pid, Process::WEXITED) }.to raise_error(TypeError)
145
+ expect { call_waitid(Process::P_PID, @pid, 'foo') }.to raise_error(TypeError)
146
+ expect { call_waitid(Process::P_PID, 'foo', Process::WEXITED) }.to raise_error(TypeError)
157
147
  end
158
148
 
159
- example 'waitid method raises expected error if invalid argument is passed' do
160
- skip 'waitid test skipped on this platform' if hpux || darwin || bsd
161
-
149
+ example 'waitid method raises expected error if invalid argument is passed', :skip_hpux do
162
150
  @pid = fork { sleep 0.5 }
163
151
  expect { described_class.waitid(Process::P_PID, 99999999, Process::WEXITED) }.to raise_error(Errno::ECHILD)
164
152
  end
165
153
 
166
- example 'sigsend method is defined' do
167
- skip 'sigsend test skipped on this platform' unless solaris
168
-
154
+ example 'sigsend method is defined', :solaris do
169
155
  expect(described_class).to respond_to(:sigsend)
170
156
  end
171
157
 
172
- example 'sigsend works as expected' do
173
- skip 'sigsend test skipped on this platform' unless solaris
174
-
158
+ example 'sigsend works as expected', :solaris do
175
159
  @pid = fork { sleep 0.5 }
176
160
  expect { described_class.sigsend(Process::P_PID, @pid, 0) }.not_to raise_error
177
161
  end
@@ -187,14 +171,11 @@ RSpec.describe Process do
187
171
  expect { described_class.getrusage(true) }.not_to raise_error
188
172
  end
189
173
 
190
- example 'getrusage can get thread info on Linux' do
191
- skip 'getrusage only tested on Linux' unless linux
174
+ example 'getrusage can get thread info on Linux', :linux do
192
175
  expect { described_class.getrusage(Process::RUSAGE_THREAD) }.not_to raise_error
193
176
  end
194
177
 
195
- example 'getrusage returns the expected struct' do
196
- skip 'getrusage only tested on Linux' unless linux
197
-
178
+ example 'getrusage returns the expected struct', :linux do
198
179
  @pid = fork { sleep 0.5 }
199
180
  expect(described_class.getrusage).to be_a(Struct::RUsage)
200
181
  expect(described_class.getrusage.stime).to be_a(Float)
@@ -205,21 +186,18 @@ RSpec.describe Process do
205
186
  expect(described_class).to respond_to(:pause)
206
187
  end
207
188
 
208
- example 'expected constants are defined' do
209
- skip 'wait constant check skipped on this platform' if darwin || bsd
210
-
189
+ example 'expected constants are defined', :skip_darwin, :skip_bsd do
211
190
  expect(Process::WCONTINUED).not_to be_nil
212
191
  expect(Process::WEXITED).not_to be_nil
213
192
  expect(Process::WNOWAIT).not_to be_nil
214
193
  expect(Process::WSTOPPED).not_to be_nil
194
+ end
215
195
 
216
- skip 'WTRAPPED constant check skipped on this platform' if linux
196
+ example 'expected constant WTRAPPED is defined', :bsd do
217
197
  expect(Process::WTRAPPED).not_to be_nil
218
198
  end
219
199
 
220
- example 'expected process type flag constants are defined' do
221
- skip 'process type flag check skipped on this platform' if linux || darwin || bsd
222
-
200
+ example 'expected process type flag constants are defined', :solaris do
223
201
  expect(Process::P_ALL).not_to be_nil
224
202
  expect(Process::P_CID).not_to be_nil
225
203
  expect(Process::P_GID).not_to be_nil
@@ -227,20 +205,15 @@ RSpec.describe Process do
227
205
  expect(Process::P_PID).not_to be_nil
228
206
  expect(Process::P_SID).not_to be_nil
229
207
  expect(Process::P_UID).not_to be_nil
230
-
231
- skip 'P_MYID constant check skipped on this platform' unless solaris
232
208
  expect(Process::P_MYID).not_to be_nil
233
209
  end
234
210
 
235
- example 'solaris-specific process type flags are defined on solaris' do
236
- skip 'P_TASKID and P_PROJID constant check skipped on this platform' unless solaris
237
-
211
+ example 'solaris-specific process type flags are defined on solaris', :solaris do
238
212
  expect(Process::P_TASKID).not_to be_nil
239
213
  expect(Process::P_PROJID).not_to be_nil
240
214
  end
241
215
 
242
- example 'bsd-specific process type flags are defined on BSD platforms' do
243
- skip 'P_JAILID constant check skipped on this platform' unless bsd
216
+ example 'bsd-specific process type flags are defined on BSD platforms', :bsd do
244
217
  expect(Process::P_JAILID).not_to be_nil
245
218
  end
246
219
 
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rspec'
4
+ require 'proc-wait3'
5
+
6
+ RSpec.configure do |config|
7
+ config.filter_run_excluding(:darwin) if Gem::Platform.local.os !~ /darwin|macos/i
8
+ config.filter_run_excluding(:solaris) if Gem::Platform.local.os !~ /sunos|solaris/i
9
+ config.filter_run_excluding(:bsd) if Gem::Platform.local.os !~ /bsd|dragonfly/i
10
+ config.filter_run_excluding(:linux) if Gem::Platform.local.os !~ /linux/i
11
+
12
+ config.filter_run_excluding(:skip_hpux) if Gem::Platform.local.os =~ /hpux/i
13
+ config.filter_run_excluding(:skip_darwin) if Gem::Platform.local.os =~ /darwin|macos/i
14
+ config.filter_run_excluding(:skip_bsd) if Gem::Platform.local.os =~ /bsd|dragonfly/i
15
+ config.filter_run_excluding(:skip_linux) if Gem::Platform.local.os =~ /linux/i
16
+ end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proc-wait3
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.2
4
+ version: 1.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - |
@@ -35,7 +35,7 @@ cert_chain:
35
35
  ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
36
  WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
37
37
  -----END CERTIFICATE-----
38
- date: 2024-04-21 00:00:00.000000000 Z
38
+ date: 2024-05-04 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rake
@@ -120,6 +120,7 @@ files:
120
120
  - lib/proc-wait3.rb
121
121
  - proc-wait3.gemspec
122
122
  - spec/proc_wait3_spec.rb
123
+ - spec/spec_helper.rb
123
124
  homepage: https://github.com/djberg96/proc-wait3
124
125
  licenses:
125
126
  - Apache-2.0
@@ -132,7 +133,7 @@ metadata:
132
133
  wiki_uri: https://github.com/djberg96/proc-wait3/wiki
133
134
  rubygems_mfa_required: 'true'
134
135
  github_repo: https://github.com/djberg96/proc-wait3
135
- post_install_message:
136
+ post_install_message:
136
137
  rdoc_options: []
137
138
  require_paths:
138
139
  - lib
@@ -147,8 +148,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
148
  - !ruby/object:Gem::Version
148
149
  version: '0'
149
150
  requirements: []
150
- rubygems_version: 3.3.26
151
- signing_key:
151
+ rubygems_version: 3.4.19
152
+ signing_key:
152
153
  specification_version: 4
153
154
  summary: Adds wait3, wait4 and other methods to the Process module
154
155
  test_files:
metadata.gz.sig CHANGED
Binary file