proc-wait3 1.9.1 → 1.9.2

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: d2054430d4049b9aa27f1902f704220818bf4e6b8d7d19e428e10e3ed736d6c9
4
- data.tar.gz: 9be23be7ddad009649f5ec83692102b05334a9013d99a68f1643c1c2eda37b62
3
+ metadata.gz: a6e56b25dc085ce18c5808a81d259c4e9f54cb75d1ff985985bb5a575d58ed90
4
+ data.tar.gz: 65379d28529797369401cc65abb6c234b9cf1995ec7cf92152d03c03c6a89a83
5
5
  SHA512:
6
- metadata.gz: a6f95da3b81622fd0a4ca7be57f787ec63201be854f28bcb023aec9af3360ef8ec6af228ca3c180dfa7163831456aa57fd68ced837cb40d46f3b262e2a2b4554
7
- data.tar.gz: fff3abd919e4c0f07ab666ea3f3a1db8d514fa63802fd408b57c87f0c8208d6cf4e886813605156625bc00e8b931405098e5a714d34a91a00830287974603507
6
+ metadata.gz: 51f2d1148e8fcadb8b9530420ac164e81b4645b04e3f7b8acded43a62acaa3000240f5e5e53b5fda4cc734f0e2f76edbf76d5b325c2cc3fefd450cf0f60ca519
7
+ data.tar.gz: ce1e71899e8db9c2c74bb5207d3a715e7cf8b355d0c5b6bc203b51608647d90fe53c0414bce48ee38c1c796987df7f9fa2b4a30c9eeebdd35900e34d288be82a
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGES.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 1.9.2 - 21-Apr-2024
2
+ * Added the P_JAILID constant for BSD platforms.
3
+ * Added some notes to the README for coping with EINTR.
4
+ * Added rubocop and rubocop-rspec as dev dependencies and did
5
+ some general rubocop cleanup.
6
+
1
7
  ## 1.9.1 - 8-Feb-2024
2
8
  * Replace sigset with sigaction in the pause method.
3
9
  * General cleanup and platform handling updates.
data/README.md CHANGED
@@ -38,6 +38,38 @@ These methods may fail in conjunction with `fork` with `Errno::EINTR` unless
38
38
  you pass the WNOHANG flag, or explicitly ignore the `SIGCHLD` signal. Ruby's
39
39
  own `wait` methods appear to essentially be doing that behind the scenes.
40
40
 
41
+ Note that on some platforms just setting a `SIGCHLD` handler may not be
42
+ enough to prevent an `Errno::EINTR` from occuring since you can never be sure
43
+ what signal it's going to receive. Since this appears to be coming from the
44
+ guts of the Ruby core code itself IMO, it's somewhat out of my hands, but it's
45
+ not impossible to deal with.
46
+
47
+ A typical idiom would be to simulate the `TEMP_FAILURE_RETRY` macro that the GNU
48
+ library provides. This macro wraps a given function and retries it so long as
49
+ it doesn't fail, or the only failure is an `EINTR`. I've chosen not to integrate
50
+ this into the code directly (yet), but you can simulate it like so:
51
+
52
+ ```ruby
53
+ require 'English'
54
+
55
+ begin
56
+ pid = fork{ sleep 1; exit 2 }
57
+ Process.wait3
58
+ rescue Errno::EINTR
59
+ retry
60
+ end
61
+
62
+ p $CHILD_STATUS
63
+ ```
64
+
65
+ For more information please see:
66
+
67
+ https://www.gnu.org/savannah-checkouts/gnu/libc/manual/html_node/Interrupted-Primitives.html
68
+
69
+ BSD provides another approach using sigaction handlers + `SA_RESTART`, but it requires knowing
70
+ the signal type in advance. So, unless you want to apply the same handler to *every* type of
71
+ signal, I don't find it especially useful.
72
+
41
73
  ## Integration with Ruby's process.c
42
74
  I considered simply providing a patch to the core process.c file, but I
43
75
  decided against it for two reasons. First, I wanted to get something
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'rake'
2
2
  require 'rake/clean'
3
3
  require 'rspec/core/rake_task'
4
+ require 'rubocop/rake_task'
4
5
  require 'fileutils'
5
6
  require 'rbconfig'
6
7
  include RbConfig
@@ -27,7 +28,7 @@ task :build => [:clean] do |t|
27
28
  end
28
29
 
29
30
  namespace :gem do
30
- desc "Create the proc-wait3 gem"
31
+ desc 'Create the proc-wait3 gem'
31
32
  task :create => [:clean] do
32
33
  require 'rubygems/package'
33
34
  spec = Gem::Specification.load('proc-wait3.gemspec')
@@ -35,7 +36,7 @@ namespace :gem do
35
36
  Gem::Package.build(spec)
36
37
  end
37
38
 
38
- desc "Install the proc-wait3 gem"
39
+ desc 'Install the proc-wait3 gem'
39
40
  task :install => [:create] do |t|
40
41
  file = Dir['*.gem'].first
41
42
  sh "gem install -l #{file}"
@@ -69,9 +70,11 @@ namespace :example do
69
70
  end
70
71
  end
71
72
 
72
- desc "Run the test suite"
73
+ desc 'Run the test suite'
73
74
  RSpec::Core::RakeTask.new(:spec) do |t|
74
75
  t.rspec_opts = '-Iext'
75
76
  end
76
77
 
77
78
  task :default => [:build, :spec]
79
+
80
+ RuboCop::RakeTask.new
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ########################################################################
2
4
  # example_getrusage.rb
3
5
  #
@@ -11,7 +13,7 @@ require 'pp'
11
13
 
12
14
  # Show resource stats for this process for 30 seconds
13
15
  10.times do
14
- pp Process.getrusage
15
- puts "=" * 50
16
- sleep 3
16
+ pp Process.getrusage
17
+ puts '=' * 50
18
+ sleep 3
17
19
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #######################################################################
2
4
  # example_pause.rb
3
5
  #
@@ -9,13 +11,13 @@
9
11
  require 'rbconfig'
10
12
  require 'proc/wait3'
11
13
 
12
- puts "Pausing. Hit Ctrl-C to continue."
14
+ puts 'Pausing. Hit Ctrl-C to continue.'
13
15
 
14
16
  if RbConfig::CONFIG['host_os'] =~ /linux|darwin/i
15
- Process.pause(2)
17
+ Process.pause(2)
16
18
  else
17
- Process.pause("INT")
19
+ Process.pause('INT')
18
20
  end
19
21
 
20
- puts "Hey, thanks for hitting Ctrl-C. Continuing..."
21
- puts "Done"
22
+ puts 'Hey, thanks for hitting Ctrl-C. Continuing...'
23
+ puts 'Done'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #######################################################################
2
4
  # example_wait3.rb
3
5
  #
@@ -6,10 +8,11 @@
6
8
  #
7
9
  # Modify as you see fit.
8
10
  #######################################################################
11
+ require 'English'
9
12
  require 'proc/wait3'
10
13
 
11
- pid = fork{ sleep 1; exit 2 }
14
+ pid = fork { sleep 1; exit 2 }
12
15
 
13
16
  p Time.now
14
17
  Process.wait3
15
- p $?
18
+ p $CHILD_STATUS
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #######################################################################
2
4
  # example_wait4.rb
3
5
  #
@@ -6,9 +8,10 @@
6
8
  #
7
9
  # Modify as you see fit.
8
10
  #######################################################################
11
+ require 'English'
9
12
  require 'proc/wait3'
10
13
 
11
- pid = fork{ sleep 2 }
14
+ pid = fork { sleep 2 }
12
15
  p Time.now
13
16
  Process.wait4(pid, Process::WUNTRACED)
14
- p $?
17
+ p $CHILD_STATUS
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #######################################################################
2
4
  # example_waitid.rb
3
5
  #
@@ -6,9 +8,10 @@
6
8
  #
7
9
  # Modify as you see fit.
8
10
  #######################################################################
11
+ require 'English'
9
12
  require 'proc/wait3'
10
13
 
11
- pid = fork{ sleep 2 }
14
+ pid = fork { sleep 2 }
12
15
  p Time.now
13
16
  Process.waitid(Process::P_PID, pid, Process::WEXITED)
14
- p $?
17
+ p $CHILD_STATUS
data/ext/extconf.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ########################################################
2
4
  # Use the mkmf.rb file that I provide, so I can use the
3
5
  # have_enum_member method
@@ -12,7 +14,7 @@ have_header('sys/wait.h')
12
14
 
13
15
  # wait3 is mandatory.
14
16
  unless have_func('wait3')
15
- STDERR.puts 'wait3() function not found'
17
+ warn 'wait3() function not found'
16
18
  exit
17
19
  end
18
20
 
@@ -68,4 +70,7 @@ have_const('P_TASKID', 'signal.h')
68
70
  # RUSAGE_THREAD is Linux-specific
69
71
  have_const('RUSAGE_THREAD', 'sys/resource.h')
70
72
 
73
+ # BSD
74
+ have_const('P_JAILID', 'sys/wait.h')
75
+
71
76
  create_makefile('proc/wait3', 'proc')
data/ext/proc/wait3.c CHANGED
@@ -957,12 +957,17 @@ void Init_wait3(void)
957
957
  rb_define_const(rb_mProcess, "P_PROJID", INT2FIX(P_PROJID));
958
958
  #endif
959
959
 
960
+ #ifdef HAVE_CONST_P_JAILID
961
+ /* Process jail ID */
962
+ rb_define_const(rb_mProcess, "P_JAILID", INT2FIX(P_JAILID));
963
+ #endif
964
+
960
965
  #ifdef HAVE_CONST_RUSAGE_THREAD
961
966
  rb_define_const(rb_mProcess, "RUSAGE_THREAD", INT2FIX(RUSAGE_THREAD));
962
967
  #endif
963
968
 
964
- /* 1.9.0: The version of the proc-wait3 library */
965
- rb_define_const(rb_mProcess, "WAIT3_VERSION", rb_str_freeze(rb_str_new2("1.9.1")));
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")));
966
971
 
967
972
  /* Define this last in our Init_wait3 function */
968
973
  rb_define_readonly_variable("$last_status", &v_last_status);
data/lib/proc-wait3.rb CHANGED
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'proc/wait3'
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.1'
5
+ spec.version = '1.9.2'
6
6
  spec.author = 'Daniel J. Berger'
7
7
  spec.license = 'Apache-2.0'
8
8
  spec.email = 'djberg96@gmail.com'
@@ -10,11 +10,13 @@ Gem::Specification.new do |spec|
10
10
  spec.summary = 'Adds wait3, wait4 and other methods to the Process module'
11
11
  spec.test_file = 'spec/proc_wait3_spec.rb'
12
12
  spec.extensions = ['ext/extconf.rb']
13
- spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
13
+ spec.files = Dir['**/*'].reject { |f| f.include?('git') }
14
14
  spec.cert_chain = Dir['certs/*']
15
15
 
16
16
  spec.add_development_dependency('rake')
17
17
  spec.add_development_dependency('rspec', '~> 3.9')
18
+ spec.add_development_dependency('rubocop')
19
+ spec.add_development_dependency('rubocop-rspec')
18
20
 
19
21
  spec.metadata = {
20
22
  'homepage_uri' => 'https://github.com/djberg96/proc-wait3',
@@ -23,7 +25,8 @@ Gem::Specification.new do |spec|
23
25
  'documentation_uri' => 'https://github.com/djberg96/proc-wait3/wiki',
24
26
  'source_code_uri' => 'https://github.com/djberg96/proc-wait3',
25
27
  'wiki_uri' => 'https://github.com/djberg96/proc-wait3/wiki',
26
- 'rubygems_mfa_required' => 'true'
28
+ 'rubygems_mfa_required' => 'true',
29
+ 'github_repo' => 'https://github.com/djberg96/proc-wait3'
27
30
  }
28
31
 
29
32
  spec.description = <<-EOF
@@ -1,9 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #######################################################################
2
4
  # proc_wait3_spec.rb
3
5
  #
4
6
  # Test suite for the Ruby proc-wait3 library. You should run these
5
7
  # via the 'rake spec' task.
6
8
  #######################################################################
9
+ require 'English'
7
10
  require 'proc/wait3'
8
11
  require 'rspec'
9
12
  require 'rbconfig'
@@ -31,178 +34,178 @@ RSpec.describe Process do
31
34
  @pid = nil
32
35
  end
33
36
 
34
- example "version constant is set to expected value" do
35
- expect(Process::WAIT3_VERSION).to eq('1.9.1')
37
+ example 'version constant is set to expected value' do
38
+ expect(Process::WAIT3_VERSION).to eq('1.9.2')
36
39
  expect(Process::WAIT3_VERSION).to be_frozen
37
40
  end
38
41
 
39
- example "wait3 method is defined" do
40
- expect(Process).to respond_to(:wait3)
42
+ example 'wait3 method is defined' do
43
+ expect(described_class).to respond_to(:wait3)
41
44
  end
42
45
 
43
- example "wait3 works as expected" do
46
+ example 'wait3 works as expected' do
44
47
  skip 'wait3 test skipped on this platform' if darwin
45
- @pid = fork{ sleep 0.5 }
46
- expect{ Process.wait3 }.not_to raise_error
48
+ @pid = fork { sleep 0.5 }
49
+ expect { described_class.wait3 }.not_to raise_error
47
50
  end
48
51
 
49
- example "wait3 returns the expected proc status members" do
52
+ example 'wait3 returns the expected proc status members' do
50
53
  skip 'wait3 test skipped on this platform' if darwin
51
- @pid = fork{ sleep 0.5 }
52
- expect{ @proc_stat = Process.wait3 }.not_to raise_error
53
- expect( @proc_stat.members).to eq(proc_stat_members)
54
+ @pid = fork { sleep 0.5 }
55
+ expect { @proc_stat = described_class.wait3 }.not_to raise_error
56
+ expect(@proc_stat.members).to eq(proc_stat_members)
54
57
  end
55
58
 
56
- example "wait3 with WNOHANG works as expected" do
57
- @pid = fork{ sleep 0.5 }
58
- expect{ Process.wait3(Process::WNOHANG) }.not_to raise_error
59
+ example 'wait3 with WNOHANG works as expected' do
60
+ @pid = fork { sleep 0.5 }
61
+ expect { described_class.wait3(Process::WNOHANG) }.not_to raise_error
59
62
  end
60
63
 
61
- example "wait3 sets and returns $last_status to expected values" do
64
+ example 'wait3 sets and returns $last_status to expected values' do
62
65
  skip 'wait3 test skipped on this platform' if darwin
63
- @pid = fork{ sleep 0.5 }
64
- Process.wait3
65
- expect($last_status).to be_kind_of(Struct::ProcStat)
66
+ @pid = fork { sleep 0.5 }
67
+ described_class.wait3
68
+ expect($last_status).to be_a(Struct::ProcStat)
66
69
  expect($last_status).not_to be_nil
67
70
  end
68
71
 
69
- example "wait3 sets pid and status members of $?" do
72
+ example 'wait3 sets pid and status members of $?' do
70
73
  skip 'wait3 test skipped on this platform' if darwin
71
- @pid = fork{ sleep 0.5 }
72
- Process.wait3
73
- expect($?).not_to be_nil
74
+ @pid = fork { sleep 0.5 }
75
+ described_class.wait3
76
+ expect($CHILD_STATUS).not_to be_nil
74
77
  end
75
78
 
76
- example "wait3 returns frozen struct" do
79
+ example 'wait3 returns frozen struct' do
77
80
  skip 'wait3 test skipped on this platform' if darwin
78
- @pid = fork{ sleep 0.5 }
79
- struct = Process.wait3
81
+ @pid = fork { sleep 0.5 }
82
+ struct = described_class.wait3
80
83
  expect(struct).to be_frozen
81
84
  end
82
85
 
83
- example "getdtablesize works as expected" do
86
+ example 'getdtablesize works as expected' do
84
87
  skip 'getdtablesize skipped on this platform' unless solaris
85
88
 
86
- expect(Process).to respond_to(:getdtablesize)
87
- expect(Process.getdtablesize).to be_kind_of(Fixnum)
88
- assert(Process.getdtablesize > 0)
89
+ expect(described_class).to respond_to(:getdtablesize)
90
+ expect(described_class.getdtablesize).to be_a(Integer)
91
+ assert(described_class.getdtablesize > 0)
89
92
  end
90
93
 
91
- example "wait4 method is defined" do
94
+ example 'wait4 method is defined' do
92
95
  skip 'wait4 test skipped on this platform' if hpux
93
- expect(Process).to respond_to(:wait4)
96
+ expect(described_class).to respond_to(:wait4)
94
97
  end
95
98
 
96
- example "wait4 requires at least one argument" do
99
+ example 'wait4 requires at least one argument' do
97
100
  skip 'wait4 test skipped on this platform' if hpux
98
- expect{ Process.wait4 }.to raise_error(ArgumentError)
101
+ expect { described_class.wait4 }.to raise_error(ArgumentError)
99
102
  end
100
103
 
101
- example "wait4 works as expected" do
104
+ example 'wait4 works as expected' do
102
105
  skip 'wait4 test skipped on this platform' if hpux || darwin
103
106
 
104
- @pid = fork{ sleep 0.5 }
105
- expect{ @proc_stat = Process.wait4(@pid) }.not_to raise_error
106
- expect(@proc_stat).to be_kind_of(Struct::ProcStat)
107
+ @pid = fork { sleep 0.5 }
108
+ expect { @proc_stat = described_class.wait4(@pid) }.not_to raise_error
109
+ expect(@proc_stat).to be_a(Struct::ProcStat)
107
110
  end
108
111
 
109
- example "wait4 sets and returns $last_status to expected values" do
112
+ example 'wait4 sets and returns $last_status to expected values' do
110
113
  skip 'wait4 test skipped on this platform' if hpux || darwin
111
114
 
112
- @pid = fork{ sleep 0.5 }
113
- Process.wait4(@pid)
114
- expect($last_status).to be_kind_of(Struct::ProcStat)
115
+ @pid = fork { sleep 0.5 }
116
+ described_class.wait4(@pid)
117
+ expect($last_status).to be_a(Struct::ProcStat)
115
118
  expect($last_status).not_to be_nil
116
119
  end
117
120
 
118
- example "wait4 sets pid and status members of $?" do
121
+ example 'wait4 sets pid and status members of $?' do
119
122
  skip 'wait4 test skipped on this platform' if hpux || darwin
120
123
 
121
- @pid = fork{ sleep 0.5 }
122
- Process.wait4(@pid)
123
- expect($?).not_to be_nil
124
+ @pid = fork { sleep 0.5 }
125
+ described_class.wait4(@pid)
126
+ expect($CHILD_STATUS).not_to be_nil
124
127
  end
125
128
 
126
- example "wait4 returns frozen struct" do
129
+ example 'wait4 returns frozen struct' do
127
130
  skip 'wait4 test skipped on this platform' if hpux || darwin
128
131
 
129
- @pid = fork{ sleep 0.5 }
130
- struct = Process.wait4(@pid)
132
+ @pid = fork { sleep 0.5 }
133
+ struct = described_class.wait4(@pid)
131
134
  expect(struct).to be_frozen
132
135
  end
133
136
 
134
- example "waitid method is defined" do
137
+ example 'waitid method is defined' do
135
138
  skip 'waitid test skipped on this platform' if hpux || darwin || bsd
136
139
 
137
- expect(Process).to respond_to(:waitid)
140
+ expect(described_class).to respond_to(:waitid)
138
141
  end
139
142
 
140
- example "waitid method works as expected" do
143
+ example 'waitid method works as expected' do
141
144
  skip 'waitid test skipped on this platform' if hpux || darwin || bsd
142
145
 
143
- @pid = fork{ sleep 0.5 }
144
- expect{ Process.waitid(Process::P_PID, @pid, Process::WEXITED) }.not_to raise_error
146
+ @pid = fork { sleep 0.5 }
147
+ expect { described_class.waitid(Process::P_PID, @pid, Process::WEXITED) }.not_to raise_error
145
148
  end
146
149
 
147
- example "waitid method raises expected errors if wrong argument type is passed" do
150
+ example 'waitid method raises expected errors if wrong argument type is passed' do
148
151
  skip 'waitid test skipped on this platform' if hpux || darwin || bsd
149
152
 
150
- @pid = fork{ sleep 0.5 }
151
- expect{ Process.waitid("foo", @pid, Process::WEXITED) }.to raise_error(TypeError)
152
- expect{ Process.waitid(Process::P_PID, @pid, "foo") }.to raise_error(TypeError)
153
- expect{ Process.waitid(Process::P_PID, "foo", Process::WEXITED) }.to raise_error(TypeError)
153
+ @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)
154
157
  end
155
158
 
156
- example "waitid method raises expected error if invalid argument is passed" do
159
+ example 'waitid method raises expected error if invalid argument is passed' do
157
160
  skip 'waitid test skipped on this platform' if hpux || darwin || bsd
158
161
 
159
- @pid = fork{ sleep 0.5 }
160
- expect{ Process.waitid(Process::P_PID, 99999999, Process::WEXITED) }.to raise_error(Errno::ECHILD)
162
+ @pid = fork { sleep 0.5 }
163
+ expect { described_class.waitid(Process::P_PID, 99999999, Process::WEXITED) }.to raise_error(Errno::ECHILD)
161
164
  end
162
165
 
163
- example "sigsend method is defined" do
166
+ example 'sigsend method is defined' do
164
167
  skip 'sigsend test skipped on this platform' unless solaris
165
168
 
166
- expect(Process).to respond_to(:sigsend)
169
+ expect(described_class).to respond_to(:sigsend)
167
170
  end
168
171
 
169
- example "sigsend works as expected" do
172
+ example 'sigsend works as expected' do
170
173
  skip 'sigsend test skipped on this platform' unless solaris
171
174
 
172
- @pid = fork{ sleep 0.5 }
173
- expect{ Process.sigsend(Process::P_PID, @pid, 0) }.not_to raise_error
175
+ @pid = fork { sleep 0.5 }
176
+ expect { described_class.sigsend(Process::P_PID, @pid, 0) }.not_to raise_error
174
177
  end
175
178
 
176
- example "getrusage method is defined" do
177
- expect(Process).to respond_to(:getrusage)
179
+ example 'getrusage method is defined' do
180
+ expect(described_class).to respond_to(:getrusage)
178
181
  end
179
182
 
180
- example "getrusage works as expected" do
181
- @pid = fork{ sleep 0.5 }
183
+ example 'getrusage works as expected' do
184
+ @pid = fork { sleep 0.5 }
182
185
 
183
- expect{ Process.getrusage }.not_to raise_error
184
- expect{ Process.getrusage(true) }.not_to raise_error
186
+ expect { described_class.getrusage }.not_to raise_error
187
+ expect { described_class.getrusage(true) }.not_to raise_error
185
188
  end
186
189
 
187
- example "getrusage can get thread info on Linux" do
190
+ example 'getrusage can get thread info on Linux' do
188
191
  skip 'getrusage only tested on Linux' unless linux
189
- expect{ Process.getrusage(Process::RUSAGE_THREAD) }.not_to raise_error
192
+ expect { described_class.getrusage(Process::RUSAGE_THREAD) }.not_to raise_error
190
193
  end
191
194
 
192
- example "getrusage returns the expected struct" do
195
+ example 'getrusage returns the expected struct' do
193
196
  skip 'getrusage only tested on Linux' unless linux
194
197
 
195
- @pid = fork{ sleep 0.5 }
196
- expect(Process.getrusage).to be_kind_of(Struct::RUsage)
197
- expect(Process.getrusage.stime).to be_kind_of(Float)
198
- expect(Process.getrusage.utime).to be_kind_of(Float)
198
+ @pid = fork { sleep 0.5 }
199
+ expect(described_class.getrusage).to be_a(Struct::RUsage)
200
+ expect(described_class.getrusage.stime).to be_a(Float)
201
+ expect(described_class.getrusage.utime).to be_a(Float)
199
202
  end
200
203
 
201
- example "pause method is defined" do
202
- expect(Process).to respond_to(:pause)
204
+ example 'pause method is defined' do
205
+ expect(described_class).to respond_to(:pause)
203
206
  end
204
207
 
205
- example "expected constants are defined" do
208
+ example 'expected constants are defined' do
206
209
  skip 'wait constant check skipped on this platform' if darwin || bsd
207
210
 
208
211
  expect(Process::WCONTINUED).not_to be_nil
@@ -214,7 +217,7 @@ RSpec.describe Process do
214
217
  expect(Process::WTRAPPED).not_to be_nil
215
218
  end
216
219
 
217
- example "expected process type flag constants are defined" do
220
+ example 'expected process type flag constants are defined' do
218
221
  skip 'process type flag check skipped on this platform' if linux || darwin || bsd
219
222
 
220
223
  expect(Process::P_ALL).not_to be_nil
@@ -229,13 +232,18 @@ RSpec.describe Process do
229
232
  expect(Process::P_MYID).not_to be_nil
230
233
  end
231
234
 
232
- example "solaris-specific process type flags are defined on solaris" do
235
+ example 'solaris-specific process type flags are defined on solaris' do
233
236
  skip 'P_TASKID and P_PROJID constant check skipped on this platform' unless solaris
234
237
 
235
238
  expect(Process::P_TASKID).not_to be_nil
236
239
  expect(Process::P_PROJID).not_to be_nil
237
240
  end
238
241
 
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
244
+ expect(Process::P_JAILID).not_to be_nil
245
+ end
246
+
239
247
  def after
240
248
  Process.kill(9, @pid) if @pid
241
249
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proc-wait3
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.1
4
+ version: 1.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -35,7 +35,7 @@ cert_chain:
35
35
  ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
36
  WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
37
37
  -----END CERTIFICATE-----
38
- date: 2024-02-08 00:00:00.000000000 Z
38
+ date: 2024-04-21 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rake
@@ -65,6 +65,34 @@ dependencies:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
67
  version: '3.9'
68
+ - !ruby/object:Gem::Dependency
69
+ name: rubocop
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ - !ruby/object:Gem::Dependency
83
+ name: rubocop-rspec
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
68
96
  description: |2
69
97
  The proc-wait3 library adds the wait3, wait4, waitid, pause, sigsend,
70
98
  and getrusage methods to the Process module.
@@ -103,6 +131,7 @@ metadata:
103
131
  source_code_uri: https://github.com/djberg96/proc-wait3
104
132
  wiki_uri: https://github.com/djberg96/proc-wait3/wiki
105
133
  rubygems_mfa_required: 'true'
134
+ github_repo: https://github.com/djberg96/proc-wait3
106
135
  post_install_message:
107
136
  rdoc_options: []
108
137
  require_paths:
@@ -118,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
147
  - !ruby/object:Gem::Version
119
148
  version: '0'
120
149
  requirements: []
121
- rubygems_version: 3.1.6
150
+ rubygems_version: 3.3.26
122
151
  signing_key:
123
152
  specification_version: 4
124
153
  summary: Adds wait3, wait4 and other methods to the Process module
metadata.gz.sig CHANGED
Binary file