proc-wait3 1.9.0 → 1.9.1

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: 833ae8756453e432d042610abec187891cd8c53c9c03f942a247cc0f6488979b
4
- data.tar.gz: 873ae57b81c82f55f9a34e975ae53eb71319d8c65fde352bfef7bd62f9000cb4
3
+ metadata.gz: d2054430d4049b9aa27f1902f704220818bf4e6b8d7d19e428e10e3ed736d6c9
4
+ data.tar.gz: 9be23be7ddad009649f5ec83692102b05334a9013d99a68f1643c1c2eda37b62
5
5
  SHA512:
6
- metadata.gz: 2798ca928c06bd913b04665f7adcd02ac73f2d6d742e30c7d08e15a56c7a284e9cd2cc3b2cb9d8c923fa82d1297fbe30488de848504ffef0cd3dd9a776a6146a
7
- data.tar.gz: 28976b3335794b2cf0bd0002dafa58c5d3b8eec326d52bd085c34afebc79f3fff838b3c2da12779089d008b037dd7b7ae56b2b2c0f0299e95eb34bb163ff88af
6
+ metadata.gz: a6f95da3b81622fd0a4ca7be57f787ec63201be854f28bcb023aec9af3360ef8ec6af228ca3c180dfa7163831456aa57fd68ced837cb40d46f3b262e2a2b4554
7
+ data.tar.gz: fff3abd919e4c0f07ab666ea3f3a1db8d514fa63802fd408b57c87f0c8208d6cf4e886813605156625bc00e8b931405098e5a714d34a91a00830287974603507
checksums.yaml.gz.sig CHANGED
@@ -1,8 +1,5 @@
1
- )���If��u�F�~(���e�|mV����(�U��b���~��?�۶;^��5]����"ion�$QduP%~չ�o
2
- / 8|i�z2�+�c���#!�:��R����5r4Ck��ot(Q��?BD�xc�#�4�����lF�f�)�~ƕwغ)]�\�1s8�.���6���im�Y�Z#��Qޘ�� 4�G;G�����)y]L@o�(���Gc�p�%
3
- t|]�j��pfB;}^} �v��Q�`����S_��凞=�����S*�ѕ�8:�
4
- �
5
- 5���_�������}��l�}�X�#���^
6
- 8�
7
- K!
8
- �9��a#q(p�Š�v�B]ڭ�N Ѡ]��_7f�汵��X�땍
1
+ ����M�]
2
+ {)��N���Xy��*\��'D.˲�g��� >BpX`�/�u���G�F'
3
+ �R�Ѐ�gG��*%.�.{Z�:�eH\vC�R�� ZE��!��|�x��#�X����7�}e ����VzT_H���N.Z�#ڴ��%I Z �[�<C��,Ca����Ì1��`�CU�ݻ0�ٶ"iO�6���!��T�*��R��6g!����r��!�S���^-aZhRCv��YOW�k��&
4
+ ?� �8�lz��������82�&5Q�_�j���l��A����!e � W�&%�F<1��)D��&��k0�Y�f���25�<�(��m����=�6�]���E
5
+ TT���b&�)
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.9.1 - 8-Feb-2024
2
+ * Replace sigset with sigaction in the pause method.
3
+ * General cleanup and platform handling updates.
4
+
1
5
  ## 1.9.0 - 7-Jan-2021
2
6
  * Switched from test-unit to rspec.
3
7
  * Skip some tests on Darwin because of EINTR errors.
data/Gemfile CHANGED
@@ -1,7 +1,2 @@
1
- source 'https://rubygems.org' do
2
- gem 'rake'
3
-
4
- group 'test' do
5
- gem 'rspec', '~> 3.9'
6
- end
7
- end
1
+ source 'https://rubygems.org'
2
+ gemspec
data/MANIFEST.md CHANGED
@@ -6,7 +6,7 @@
6
6
  * README.md
7
7
  * proc-wait3.gemspec
8
8
  * certs/djberg96_pub.pem
9
- * doc/wait3.txt
9
+ * doc/wait3.md
10
10
  * ext/extconf.rb
11
11
  * ext/proc/wait3.c
12
12
  * examples/example_getrusage.rb
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Ruby](https://github.com/djberg96/proc-wait3/actions/workflows/ruby.yml/badge.svg)](https://github.com/djberg96/proc-wait3/actions/workflows/ruby.yml)
2
+
1
3
  ## Description
2
4
  Adds the wait3, wait4, waitid, pause, sigsend, and getrusage methods to the Process module.
3
5
 
@@ -32,9 +34,9 @@ Linux users may also notice warnings about implicit declarations. These
32
34
  are also harmless, and can be silenced by installing the libbsd-dev package
33
35
  first.
34
36
 
35
- On Darwin these methods will likely fail with Errno::EINTR unless you pass
36
- the WNOHANG flag. I am not sure why, I can only speculate that the child is
37
- receiving a signal from either the Ruby interpreter or the operating system.
37
+ These methods may fail in conjunction with `fork` with `Errno::EINTR` unless
38
+ you pass the WNOHANG flag, or explicitly ignore the `SIGCHLD` signal. Ruby's
39
+ own `wait` methods appear to essentially be doing that behind the scenes.
38
40
 
39
41
  ## Integration with Ruby's process.c
40
42
  I considered simply providing a patch to the core process.c file, but I
@@ -50,4 +52,4 @@ trouble of typing the word "status", since all they're for is comparing or
50
52
  operating on the status attribute.
51
53
 
52
54
  ## Additional Documentation
53
- Please see the doc/wait3.txt file for detailed documentation.
55
+ Please see the doc/wait3.md file for detailed documentation.
data/Rakefile CHANGED
@@ -30,7 +30,7 @@ namespace :gem do
30
30
  desc "Create the proc-wait3 gem"
31
31
  task :create => [:clean] do
32
32
  require 'rubygems/package'
33
- spec = eval(IO.read('proc-wait3.gemspec'))
33
+ spec = Gem::Specification.load('proc-wait3.gemspec')
34
34
  spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
35
35
  Gem::Package.build(spec)
36
36
  end
data/doc/wait3.md ADDED
@@ -0,0 +1,225 @@
1
+ ## Description
2
+ Adds the `wait3`, `wait4`, `waitid`, `pause`, `sigsend`, and `getrusage`
3
+ methods to the Process module.
4
+
5
+ ## Synopsis
6
+ ```ruby
7
+ require 'proc/wait3'
8
+
9
+ pid = fork{ sleep 1; exit 2 }
10
+ p Time.now
11
+ Process.wait3
12
+ p $?
13
+ ```
14
+
15
+ ## Module Methods
16
+ ### `Process.pause(signals=nil)`
17
+
18
+ Pauses the current process. If the process receives any of the signals
19
+ you pass as arguments it will return from the pause and continue with
20
+ the execution of your code. Otherwise, it will exit.
21
+
22
+ Note that you must leave out the 'SIG' prefix for the signal name, e.g.
23
+ use 'INT', not 'SIGINT'.
24
+
25
+ Returns the result of the underlying `pause()` function, which should always be -1.
26
+
27
+ ### `Process.sigsend(idtype, id, signal=0)`
28
+
29
+ Sends a signal of type "idtype" to a process or process group "id". This
30
+ is more versatile method of sending signals to processes than Process.kill.
31
+
32
+ For a list of valid idtype values, see the "Process type constants" below.
33
+ Not supported on all platforms.
34
+
35
+ ### `Proc.wait3(flags=0)`
36
+
37
+ Delays its caller until a signal is received or one of its child processes
38
+ terminates or stops due to tracing.
39
+
40
+ The return value is a ProcStat structure and sets the `$last_status` global
41
+ variable. The special global $? is also set. Raises a SystemError if there
42
+ are no child processes.
43
+
44
+ ### `Proc.wait4(pid, flags=0)`
45
+
46
+ Waits for the given child process to exit. Returns a ProcStat structure.
47
+ The `$last_status` global variable is set. Also sets the `$?` special global
48
+ variable.
49
+
50
+ ### `Proc.waitid(id_type, id_num=nil, options=nil)`
51
+
52
+ Suspends the calling process until one of its children changes state,
53
+ returning immediately if a child process changed state prior to the call.
54
+ The state of a child process will change if it terminates, stops because
55
+ of a signal, becomes trapped or reaches a breakpoint.
56
+
57
+ The `id_num` corresponds to a process ID or process group ID, depending on
58
+ the value of `id_type`, which may be `Process::P_PID`, `Process::P_PGID` or
59
+ `Process::P_ALL`. If `id_type` is `Process::P_ALL`, then the `id_num` is ignored.
60
+
61
+ The options argument is used to specify which state changes are to be
62
+ waited for. It is constructed from the bitwise-OR of one or more of the
63
+ following constants:
64
+
65
+ * Process::WCONTINUED
66
+ * Process::WEXITED
67
+ * Process::WNOHANG
68
+ * Process::WNOWAIT
69
+ * Process::WSTOPPED
70
+ * Process::WTRAPPED (not supported on all platforms)
71
+
72
+ If `Process::WNOHANG` is set as an option, this method will return
73
+ immediately, whether or not a child has changed state.
74
+
75
+ Calling this method with an `id_type` of `Process::P_ALL` and the options set
76
+ to `Process::EXITED | Process::WTRAPPED` is equivalent to calling
77
+ Process.wait.
78
+
79
+ Returns a `Proc::SigInfo` struct and sets `$?`.
80
+
81
+ Not supported on all platforms.
82
+
83
+ ## Standard Constants
84
+ `Process::WAIT3_VERSION`
85
+
86
+ Returns the version of this package as a string.
87
+
88
+ ## Process type constants - all platforms
89
+ `Process::P_ALL`
90
+
91
+ All non-system process.
92
+
93
+ `Process::P_PID`
94
+
95
+ A standard process id.
96
+
97
+ `Process::P_PGID`
98
+
99
+ Any non-system process group id.
100
+
101
+ ## Process type constants - not all platforms supported
102
+ `Process::P_CID`
103
+
104
+ A scheduler process id.
105
+
106
+ `Process::P_GID`
107
+
108
+ Any non-system effective process group id.
109
+
110
+ `Process::P_PROJID`
111
+
112
+ A project process id. Solaris 8 or later only.
113
+
114
+ `Process::P_SID`
115
+
116
+ A session process id.
117
+
118
+ `Process::P_TASKID`
119
+
120
+ A task process id. Solaris 8 or later only.
121
+
122
+ `Process::P_UID`
123
+
124
+ Any non-system effective process user id.
125
+
126
+ ## Additional Process constants - defined if waitid is defined on your system
127
+ `Process::WCONTINUED`
128
+
129
+ Return the status for any child that was stopped and has been continued.
130
+
131
+ `Process::WEXITED`
132
+
133
+ Wait for process(es) to exit.
134
+
135
+ `Process::WNOWAIT`
136
+
137
+ Keep the process in a waitable state.
138
+
139
+ `Process::WSTOPPED`
140
+
141
+ Wait for and return the process status of any child that has stopped upon
142
+ receipt of a signal.
143
+
144
+ `Process::WTRAPPED`
145
+
146
+ Wait for traced process(es) to become trapped or reach a breakpoint.
147
+
148
+ Not supported on all platforms.
149
+
150
+ ## RLIMIT constants
151
+ `Process::RLIMIT_AS`
152
+
153
+ A synonym for `RLIMIT_VMEM`.
154
+
155
+ `Process::RLIMIT_CORE`
156
+
157
+ The maximum size of a core file, in bytes, that may be created.
158
+
159
+ `Process::RLIMIT_CPU`
160
+
161
+ The maximum amount of CPU time, in seconds, the process is allowed to use.
162
+
163
+ `Process::RLIMIT_DATA`
164
+
165
+ The maximum size of the process' heap size, in bytes.
166
+
167
+ `Process::RLIMIT_FSIZE`
168
+
169
+ The maximum size of a file, in bytes, that the process may create.
170
+
171
+ `Process::RLIMIT_NOFILE`
172
+
173
+ The maximum value that the kernel may assign to a file descriptor,
174
+ effectively limiting the number of open files for the calling process.
175
+
176
+ `Process::RLIMIT_STACK`
177
+
178
+ The maximum size of the process' stack in bytes.
179
+
180
+ `Process::RLIMIT_VMEM`
181
+
182
+ The maximum size of the process' mapped address space.
183
+
184
+ `Process::RLIM_INFINITY`
185
+
186
+ A infinite limit.
187
+
188
+ `Process::RLIM_SAVED_CUR`
189
+
190
+ Current soft limit.
191
+
192
+ `Process::RLIM_SAVED_MAX`
193
+
194
+ Current hard limit.
195
+
196
+ ## Notes
197
+ The `wait3` and `wait4` methods are similar to the `wait2` and `waitpid2`
198
+ methods, except that they return much more information via the rusage
199
+ struct.
200
+
201
+ ## Future Plans
202
+ Wrap the wait6 function, and add better BSD support in general.
203
+
204
+ ## Known Bugs
205
+ None that I'm aware of. Please log any bugs on the Github project
206
+ page at https://github.com/djberg96/proc-wait3.
207
+
208
+ ## License
209
+ Apache-2.0
210
+
211
+ ## Copyright
212
+ (C) 2003-2024 Daniel J. Berger
213
+
214
+ All Rights Reserved.
215
+
216
+ ## Warranty
217
+ This package is provided "as is" and without any express or
218
+ implied warranties, including, without limitation, the implied
219
+ warranties of merchantability and fitness for a particular purpose.
220
+
221
+ ## Author
222
+ Daniel J. Berger
223
+
224
+ ## See also
225
+ wait3, wait4, waitid, pause, sigsend
@@ -11,7 +11,7 @@ require 'proc/wait3'
11
11
 
12
12
  puts "Pausing. Hit Ctrl-C to continue."
13
13
 
14
- if Config::CONFIG['host_os'] =~ /linux/i
14
+ if RbConfig::CONFIG['host_os'] =~ /linux|darwin/i
15
15
  Process.pause(2)
16
16
  else
17
17
  Process.pause("INT")
data/ext/extconf.rb CHANGED
@@ -7,7 +7,7 @@ require 'mkmf'
7
7
  dir_config('proc-wait3')
8
8
 
9
9
  have_header('wait.h')
10
- have_header('sys/resource.h')
10
+ have_header('sys/resource.h') # apt install libbsd-dev
11
11
  have_header('sys/wait.h')
12
12
 
13
13
  # wait3 is mandatory.
@@ -53,20 +53,7 @@ have_struct_member('struct siginfo', 'si_stime', 'signal.h')
53
53
 
54
54
  have_const('P_CID', 'signal.h')
55
55
  have_const('P_GID', 'signal.h')
56
- have_const('P_MYID', 'signal.hclass PasswdStruct < FFI::Struct
57
- layout(
58
- :pw_name, :string,
59
- :pw_passwd, :string,
60
- :pw_uid, :uint,
61
- :pw_gid, :uint,
62
- :pw_change, :ulong,
63
- :pw_class, :string,
64
- :pw_gecos, :string,
65
- :pw_dir, :string,
66
- :pw_shell, :string,
67
- :pw_expire, :ulong
68
- )
69
- end')
56
+ have_const('P_MYID', 'signal.h')
70
57
  have_const('P_SID', 'signal.h')
71
58
  have_const('P_UID', 'signal.h')
72
59
 
data/ext/proc/wait3.c CHANGED
@@ -29,7 +29,7 @@
29
29
  VALUE v_last_status;
30
30
  VALUE v_procstat_struct, v_siginfo_struct, v_usage_struct;
31
31
 
32
- static void sigproc(int signum);
32
+ static void sigproc(int signum, siginfo_t* info, void* ucontext);
33
33
 
34
34
  /*
35
35
  * Returns true if this process is stopped. This is only returned
@@ -163,22 +163,22 @@ static VALUE proc_wait3(int argc, VALUE *argv, VALUE mod){
163
163
  v_last_status = rb_struct_new(v_procstat_struct,
164
164
  INT2FIX(pid),
165
165
  INT2FIX(status),
166
- INT2FIX(r.ru_utime.tv_sec + (r.ru_utime.tv_usec/1e6)),
167
- INT2FIX(r.ru_stime.tv_sec + (r.ru_stime.tv_usec/1e6)),
168
- INT2FIX(r.ru_maxrss),
169
- INT2FIX(r.ru_ixrss),
170
- INT2FIX(r.ru_idrss),
171
- INT2FIX(r.ru_isrss),
172
- INT2FIX(r.ru_minflt),
173
- INT2FIX(r.ru_majflt),
174
- INT2FIX(r.ru_nswap),
175
- INT2FIX(r.ru_inblock),
176
- INT2FIX(r.ru_oublock),
177
- INT2FIX(r.ru_msgsnd),
178
- INT2FIX(r.ru_msgrcv),
179
- INT2FIX(r.ru_nsignals),
180
- INT2FIX(r.ru_nvcsw),
181
- INT2FIX(r.ru_nivcsw),
166
+ rb_float_new((double)r.ru_utime.tv_sec+(double)r.ru_utime.tv_usec/1e6),
167
+ rb_float_new((double)r.ru_stime.tv_sec+(double)r.ru_stime.tv_usec/1e6),
168
+ LONG2NUM(r.ru_maxrss),
169
+ LONG2NUM(r.ru_ixrss),
170
+ LONG2NUM(r.ru_idrss),
171
+ LONG2NUM(r.ru_isrss),
172
+ LONG2NUM(r.ru_minflt),
173
+ LONG2NUM(r.ru_majflt),
174
+ LONG2NUM(r.ru_nswap),
175
+ LONG2NUM(r.ru_inblock),
176
+ LONG2NUM(r.ru_oublock),
177
+ LONG2NUM(r.ru_msgsnd),
178
+ LONG2NUM(r.ru_msgrcv),
179
+ LONG2NUM(r.ru_nsignals),
180
+ LONG2NUM(r.ru_nvcsw),
181
+ LONG2NUM(r.ru_nivcsw),
182
182
  pst_wifstopped(status),
183
183
  pst_wifsignaled(status),
184
184
  pst_wifexited(status),
@@ -235,22 +235,22 @@ static VALUE proc_wait4(int argc, VALUE *argv, VALUE mod){
235
235
  v_last_status = rb_struct_new(v_procstat_struct,
236
236
  INT2FIX(pid),
237
237
  INT2FIX(status),
238
- INT2FIX(r.ru_utime.tv_sec + (r.ru_utime.tv_usec/1e6)),
239
- INT2FIX(r.ru_stime.tv_sec + (r.ru_stime.tv_usec/1e6)),
240
- INT2FIX(r.ru_maxrss),
241
- INT2FIX(r.ru_ixrss),
242
- INT2FIX(r.ru_idrss),
243
- INT2FIX(r.ru_isrss),
244
- INT2FIX(r.ru_minflt),
245
- INT2FIX(r.ru_majflt),
246
- INT2FIX(r.ru_nswap),
247
- INT2FIX(r.ru_inblock),
248
- INT2FIX(r.ru_oublock),
249
- INT2FIX(r.ru_msgsnd),
250
- INT2FIX(r.ru_msgrcv),
251
- INT2FIX(r.ru_nsignals),
252
- INT2FIX(r.ru_nvcsw),
253
- INT2FIX(r.ru_nivcsw),
238
+ rb_float_new((double)r.ru_utime.tv_sec+(double)r.ru_utime.tv_usec/1e6),
239
+ rb_float_new((double)r.ru_stime.tv_sec+(double)r.ru_stime.tv_usec/1e6),
240
+ LONG2NUM(r.ru_maxrss),
241
+ LONG2NUM(r.ru_ixrss),
242
+ LONG2NUM(r.ru_idrss),
243
+ LONG2NUM(r.ru_isrss),
244
+ LONG2NUM(r.ru_minflt),
245
+ LONG2NUM(r.ru_majflt),
246
+ LONG2NUM(r.ru_nswap),
247
+ LONG2NUM(r.ru_inblock),
248
+ LONG2NUM(r.ru_oublock),
249
+ LONG2NUM(r.ru_msgsnd),
250
+ LONG2NUM(r.ru_msgrcv),
251
+ LONG2NUM(r.ru_nsignals),
252
+ LONG2NUM(r.ru_nvcsw),
253
+ LONG2NUM(r.ru_nivcsw),
254
254
  pst_wifstopped(status),
255
255
  pst_wifsignaled(status),
256
256
  pst_wifexited(status),
@@ -572,7 +572,7 @@ static VALUE proc_waitid(int argc, VALUE* argv, VALUE mod){
572
572
  */
573
573
  static VALUE proc_pause(int argc, VALUE* argv, VALUE mod){
574
574
  VALUE v_signals;
575
- int i;
575
+ int i, res;
576
576
  long len;
577
577
 
578
578
  rb_scan_args(argc, argv, "0*", &v_signals);
@@ -585,6 +585,7 @@ static VALUE proc_pause(int argc, VALUE* argv, VALUE mod){
585
585
  char signame[SIG2STR_MAX];
586
586
  unsigned int max = SIG2STR_MAX;
587
587
  int signum;
588
+ struct sigaction act, sa;
588
589
 
589
590
  for(i = 0; i < len; i++){
590
591
  v_val = rb_ary_shift(v_signals);
@@ -613,7 +614,13 @@ static VALUE proc_pause(int argc, VALUE* argv, VALUE mod){
613
614
  signum = NUM2INT(v_val);
614
615
  }
615
616
 
616
- sigset(signum, sigproc);
617
+ memset(&act, 0, sizeof(act));
618
+ act.sa_flags = SA_SIGINFO;
619
+ act.sa_sigaction = sigproc;
620
+ res = sigaction(signum, &act, &sa);
621
+
622
+ if(res)
623
+ rb_sys_fail("sigaction");
617
624
  }
618
625
  }
619
626
 
@@ -624,7 +631,7 @@ static VALUE proc_pause(int argc, VALUE* argv, VALUE mod){
624
631
  * This is just a placeholder proc to prevent the "pause" method from exiting
625
632
  * the program if the appropriate signal is intercepted.
626
633
  */
627
- static void sigproc(int signum){ /* Do nothing */ }
634
+ static void sigproc(int signum, siginfo_t* info, void* ucontext){ /* Do nothing */ }
628
635
 
629
636
  #ifdef HAVE_SIGSEND
630
637
  /*
@@ -787,7 +794,7 @@ static VALUE proc_getdtablesize(VALUE mod){
787
794
  * Adds the wait3, wait4, waitid, pause, sigsend, and getrusage methods to the
788
795
  * Process module.
789
796
  */
790
- void Init_wait3()
797
+ void Init_wait3(void)
791
798
  {
792
799
  v_procstat_struct =
793
800
  rb_struct_define("ProcStat","pid","status","utime","stime","maxrss",
@@ -955,7 +962,7 @@ void Init_wait3()
955
962
  #endif
956
963
 
957
964
  /* 1.9.0: The version of the proc-wait3 library */
958
- rb_define_const(rb_mProcess, "WAIT3_VERSION", rb_str_freeze(rb_str_new2("1.9.0")));
965
+ rb_define_const(rb_mProcess, "WAIT3_VERSION", rb_str_freeze(rb_str_new2("1.9.1")));
959
966
 
960
967
  /* Define this last in our Init_wait3 function */
961
968
  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.0'
5
+ spec.version = '1.9.1'
6
6
  spec.author = 'Daniel J. Berger'
7
7
  spec.license = 'Apache-2.0'
8
8
  spec.email = 'djberg96@gmail.com'
@@ -17,12 +17,13 @@ Gem::Specification.new do |spec|
17
17
  spec.add_development_dependency('rspec', '~> 3.9')
18
18
 
19
19
  spec.metadata = {
20
- 'homepage_uri' => 'https://github.com/djberg96/proc-wait3',
21
- 'bug_tracker_uri' => 'https://github.com/djberg96/proc-wait3/issues',
22
- 'changelog_uri' => 'https://github.com/djberg96/proc-wait3/blob/master/CHANGES.md',
23
- 'documentation_uri' => 'https://github.com/djberg96/proc-wait3/wiki',
24
- 'source_code_uri' => 'https://github.com/djberg96/proc-wait3',
25
- 'wiki_uri' => 'https://github.com/djberg96/proc-wait3/wiki'
20
+ 'homepage_uri' => 'https://github.com/djberg96/proc-wait3',
21
+ 'bug_tracker_uri' => 'https://github.com/djberg96/proc-wait3/issues',
22
+ 'changelog_uri' => 'https://github.com/djberg96/proc-wait3/blob/main/CHANGES.md',
23
+ 'documentation_uri' => 'https://github.com/djberg96/proc-wait3/wiki',
24
+ 'source_code_uri' => 'https://github.com/djberg96/proc-wait3',
25
+ 'wiki_uri' => 'https://github.com/djberg96/proc-wait3/wiki',
26
+ 'rubygems_mfa_required' => 'true'
26
27
  }
27
28
 
28
29
  spec.description = <<-EOF
@@ -9,11 +9,14 @@ require 'rspec'
9
9
  require 'rbconfig'
10
10
 
11
11
  RSpec.describe Process do
12
+ # Something in the guts of Ruby was being a pain.
13
+ Signal.trap('CHLD', 'IGNORE') if RUBY_VERSION.to_f < 3
14
+
12
15
  let(:solaris) { RbConfig::CONFIG['host_os'] =~ /sunos|solaris/i }
13
16
  let(:darwin) { RbConfig::CONFIG['host_os'] =~ /darwin|osx/i }
14
17
  let(:hpux) { RbConfig::CONFIG['host_os'] =~ /hpux/i }
15
18
  let(:linux) { RbConfig::CONFIG['host_os'] =~ /linux/i }
16
- let(:freebsd) { RbConfig::CONFIG['host_os'] =~ /bsd/i }
19
+ let(:bsd) { RbConfig::CONFIG['host_os'] =~ /bsd|dragonfly/i }
17
20
 
18
21
  let(:proc_stat_members) {
19
22
  %i[
@@ -25,10 +28,11 @@ RSpec.describe Process do
25
28
 
26
29
  before do
27
30
  @proc_stat = nil
31
+ @pid = nil
28
32
  end
29
33
 
30
34
  example "version constant is set to expected value" do
31
- expect(Process::WAIT3_VERSION).to eq('1.9.0')
35
+ expect(Process::WAIT3_VERSION).to eq('1.9.1')
32
36
  expect(Process::WAIT3_VERSION).to be_frozen
33
37
  end
34
38
 
@@ -38,25 +42,25 @@ RSpec.describe Process do
38
42
 
39
43
  example "wait3 works as expected" do
40
44
  skip 'wait3 test skipped on this platform' if darwin
41
- fork{ sleep 0.5 }
45
+ @pid = fork{ sleep 0.5 }
42
46
  expect{ Process.wait3 }.not_to raise_error
43
47
  end
44
48
 
45
49
  example "wait3 returns the expected proc status members" do
46
50
  skip 'wait3 test skipped on this platform' if darwin
47
- fork{ sleep 0.5 }
51
+ @pid = fork{ sleep 0.5 }
48
52
  expect{ @proc_stat = Process.wait3 }.not_to raise_error
49
53
  expect( @proc_stat.members).to eq(proc_stat_members)
50
54
  end
51
55
 
52
56
  example "wait3 with WNOHANG works as expected" do
53
- fork{ sleep 0.5 }
57
+ @pid = fork{ sleep 0.5 }
54
58
  expect{ Process.wait3(Process::WNOHANG) }.not_to raise_error
55
59
  end
56
60
 
57
61
  example "wait3 sets and returns $last_status to expected values" do
58
62
  skip 'wait3 test skipped on this platform' if darwin
59
- fork{ sleep 0.5 }
63
+ @pid = fork{ sleep 0.5 }
60
64
  Process.wait3
61
65
  expect($last_status).to be_kind_of(Struct::ProcStat)
62
66
  expect($last_status).not_to be_nil
@@ -64,14 +68,14 @@ RSpec.describe Process do
64
68
 
65
69
  example "wait3 sets pid and status members of $?" do
66
70
  skip 'wait3 test skipped on this platform' if darwin
67
- fork{ sleep 0.5 }
71
+ @pid = fork{ sleep 0.5 }
68
72
  Process.wait3
69
73
  expect($?).not_to be_nil
70
74
  end
71
75
 
72
76
  example "wait3 returns frozen struct" do
73
77
  skip 'wait3 test skipped on this platform' if darwin
74
- fork{ sleep 0.5 }
78
+ @pid = fork{ sleep 0.5 }
75
79
  struct = Process.wait3
76
80
  expect(struct).to be_frozen
77
81
  end
@@ -97,16 +101,16 @@ RSpec.describe Process do
97
101
  example "wait4 works as expected" do
98
102
  skip 'wait4 test skipped on this platform' if hpux || darwin
99
103
 
100
- pid = fork{ sleep 0.5 }
101
- expect{ @proc_stat = Process.wait4(pid) }.not_to raise_error
104
+ @pid = fork{ sleep 0.5 }
105
+ expect{ @proc_stat = Process.wait4(@pid) }.not_to raise_error
102
106
  expect(@proc_stat).to be_kind_of(Struct::ProcStat)
103
107
  end
104
108
 
105
109
  example "wait4 sets and returns $last_status to expected values" do
106
110
  skip 'wait4 test skipped on this platform' if hpux || darwin
107
111
 
108
- pid = fork{ sleep 0.5 }
109
- Process.wait4(pid)
112
+ @pid = fork{ sleep 0.5 }
113
+ Process.wait4(@pid)
110
114
  expect($last_status).to be_kind_of(Struct::ProcStat)
111
115
  expect($last_status).not_to be_nil
112
116
  end
@@ -114,45 +118,45 @@ RSpec.describe Process do
114
118
  example "wait4 sets pid and status members of $?" do
115
119
  skip 'wait4 test skipped on this platform' if hpux || darwin
116
120
 
117
- pid = fork{ sleep 0.5 }
118
- Process.wait4(pid)
121
+ @pid = fork{ sleep 0.5 }
122
+ Process.wait4(@pid)
119
123
  expect($?).not_to be_nil
120
124
  end
121
125
 
122
126
  example "wait4 returns frozen struct" do
123
127
  skip 'wait4 test skipped on this platform' if hpux || darwin
124
128
 
125
- pid = fork{ sleep 0.5 }
126
- struct = Process.wait4(pid)
129
+ @pid = fork{ sleep 0.5 }
130
+ struct = Process.wait4(@pid)
127
131
  expect(struct).to be_frozen
128
132
  end
129
133
 
130
134
  example "waitid method is defined" do
131
- skip 'waitid test skipped on this platform' if hpux || darwin || freebsd
135
+ skip 'waitid test skipped on this platform' if hpux || darwin || bsd
132
136
 
133
137
  expect(Process).to respond_to(:waitid)
134
138
  end
135
139
 
136
140
  example "waitid method works as expected" do
137
- skip 'waitid test skipped on this platform' if hpux || darwin || freebsd
141
+ skip 'waitid test skipped on this platform' if hpux || darwin || bsd
138
142
 
139
- pid = fork{ sleep 0.5 }
140
- expect{ Process.waitid(Process::P_PID, pid, Process::WEXITED) }.not_to raise_error
143
+ @pid = fork{ sleep 0.5 }
144
+ expect{ Process.waitid(Process::P_PID, @pid, Process::WEXITED) }.not_to raise_error
141
145
  end
142
146
 
143
147
  example "waitid method raises expected errors if wrong argument type is passed" do
144
- skip 'waitid test skipped on this platform' if hpux || darwin || freebsd
148
+ skip 'waitid test skipped on this platform' if hpux || darwin || bsd
145
149
 
146
- pid = fork{ sleep 0.5 }
147
- expect{ Process.waitid("foo", pid, Process::WEXITED) }.to raise_error(TypeError)
148
- expect{ Process.waitid(Process::P_PID, pid, "foo") }.to raise_error(TypeError)
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)
149
153
  expect{ Process.waitid(Process::P_PID, "foo", Process::WEXITED) }.to raise_error(TypeError)
150
154
  end
151
155
 
152
156
  example "waitid method raises expected error if invalid argument is passed" do
153
- skip 'waitid test skipped on this platform' if hpux || darwin || freebsd
157
+ skip 'waitid test skipped on this platform' if hpux || darwin || bsd
154
158
 
155
- fork{ sleep 0.5 }
159
+ @pid = fork{ sleep 0.5 }
156
160
  expect{ Process.waitid(Process::P_PID, 99999999, Process::WEXITED) }.to raise_error(Errno::ECHILD)
157
161
  end
158
162
 
@@ -165,8 +169,8 @@ RSpec.describe Process do
165
169
  example "sigsend works as expected" do
166
170
  skip 'sigsend test skipped on this platform' unless solaris
167
171
 
168
- pid = fork{ sleep 0.5 }
169
- expect{ Process.sigsend(Process::P_PID, pid, 0) }.not_to raise_error
172
+ @pid = fork{ sleep 0.5 }
173
+ expect{ Process.sigsend(Process::P_PID, @pid, 0) }.not_to raise_error
170
174
  end
171
175
 
172
176
  example "getrusage method is defined" do
@@ -174,7 +178,7 @@ RSpec.describe Process do
174
178
  end
175
179
 
176
180
  example "getrusage works as expected" do
177
- fork{ sleep 0.5 }
181
+ @pid = fork{ sleep 0.5 }
178
182
 
179
183
  expect{ Process.getrusage }.not_to raise_error
180
184
  expect{ Process.getrusage(true) }.not_to raise_error
@@ -188,7 +192,7 @@ RSpec.describe Process do
188
192
  example "getrusage returns the expected struct" do
189
193
  skip 'getrusage only tested on Linux' unless linux
190
194
 
191
- fork{ sleep 0.5 }
195
+ @pid = fork{ sleep 0.5 }
192
196
  expect(Process.getrusage).to be_kind_of(Struct::RUsage)
193
197
  expect(Process.getrusage.stime).to be_kind_of(Float)
194
198
  expect(Process.getrusage.utime).to be_kind_of(Float)
@@ -199,7 +203,7 @@ RSpec.describe Process do
199
203
  end
200
204
 
201
205
  example "expected constants are defined" do
202
- skip 'wait constant check skipped on this platform' if darwin || freebsd
206
+ skip 'wait constant check skipped on this platform' if darwin || bsd
203
207
 
204
208
  expect(Process::WCONTINUED).not_to be_nil
205
209
  expect(Process::WEXITED).not_to be_nil
@@ -211,7 +215,7 @@ RSpec.describe Process do
211
215
  end
212
216
 
213
217
  example "expected process type flag constants are defined" do
214
- skip 'process type flag check skipped on this platform' if linux || darwin || freebsd
218
+ skip 'process type flag check skipped on this platform' if linux || darwin || bsd
215
219
 
216
220
  expect(Process::P_ALL).not_to be_nil
217
221
  expect(Process::P_CID).not_to be_nil
@@ -231,4 +235,8 @@ RSpec.describe Process do
231
235
  expect(Process::P_TASKID).not_to be_nil
232
236
  expect(Process::P_PROJID).not_to be_nil
233
237
  end
238
+
239
+ def after
240
+ Process.kill(9, @pid) if @pid
241
+ end
234
242
  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.0
4
+ version: 1.9.1
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: 2021-01-07 00:00:00.000000000 Z
38
+ date: 2024-02-08 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rake
@@ -81,7 +81,7 @@ files:
81
81
  - README.md
82
82
  - Rakefile
83
83
  - certs/djberg96_pub.pem
84
- - doc/wait3.txt
84
+ - doc/wait3.md
85
85
  - examples/example_getrusage.rb
86
86
  - examples/example_pause.rb
87
87
  - examples/example_wait3.rb
@@ -98,10 +98,11 @@ licenses:
98
98
  metadata:
99
99
  homepage_uri: https://github.com/djberg96/proc-wait3
100
100
  bug_tracker_uri: https://github.com/djberg96/proc-wait3/issues
101
- changelog_uri: https://github.com/djberg96/proc-wait3/blob/master/CHANGES.md
101
+ changelog_uri: https://github.com/djberg96/proc-wait3/blob/main/CHANGES.md
102
102
  documentation_uri: https://github.com/djberg96/proc-wait3/wiki
103
103
  source_code_uri: https://github.com/djberg96/proc-wait3
104
104
  wiki_uri: https://github.com/djberg96/proc-wait3/wiki
105
+ rubygems_mfa_required: 'true'
105
106
  post_install_message:
106
107
  rdoc_options: []
107
108
  require_paths:
@@ -117,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
118
  - !ruby/object:Gem::Version
118
119
  version: '0'
119
120
  requirements: []
120
- rubygems_version: 3.0.3
121
+ rubygems_version: 3.1.6
121
122
  signing_key:
122
123
  specification_version: 4
123
124
  summary: Adds wait3, wait4 and other methods to the Process module
metadata.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- =+����Nv'�,��ס�%:� ���h���:/}��}Dc����'5�NL$q L��T�㼨��q�؊e۾��䗺4�&���M-K��zrE,�R&��l΁'fX�^N3w;w ��=�Ho��V�R��s�˖�?d6G
2
- �8��pw ��~ط��?������3��=���Y����t����5�X�!v�ʷf��lX ���M�2Y`���ԱR��ȒM��L*f��
1
+ �2��z"+�t|��ҺL�U��P�y�OM�ي�Q�����3S��pL�8hv�.���JLUy����O�M'q"Hl-������gіEHGh8����*��vQ�Wr���̩�_�ň찻7��H'MzQS)��e��EF�,���#g�2>�)�=�������
2
+ �^�ا���2�h����X����2�N�7����a����k[�> [P��iSG�|
data/doc/wait3.txt DELETED
@@ -1,192 +0,0 @@
1
- == Description
2
- Adds the wait3, wait4, waitid, pause, sigsend, and getrusage methods to
3
- the Process module.
4
-
5
- == Synopsis
6
- require 'proc/wait3'
7
-
8
- pid = fork{ sleep 1; exit 2 }
9
- p Time.now
10
- Process.wait3
11
- p $?
12
-
13
- == Module Methods
14
- Proc.pause(signals=nil)
15
- Pauses the current process. If the process receives any of the signals
16
- you pass as arguments it will return from the pause and continue with
17
- the execution of your code. Otherwise, it will exit.
18
-
19
- Note that you must leave out the 'SIG' prefix for the signal name, e.g.
20
- use 'INT', not 'SIGINT'.
21
-
22
- Returns the result of the pause() function, which should always be -1.
23
-
24
- Process.sigsend(idtype, id, signal=0)
25
- Sends a signal of type "idtype" to a process or process group "id". This
26
- is more versatile method of sending signals to processes than Process.kill.
27
-
28
- For a list of valid idtype values, see the "Process type constants" below.
29
- Not supported on all platforms.
30
-
31
- Proc.wait3(flags=0)
32
- Delays its caller until a signal is received or one of its child processes
33
- terminates or stops due to tracing.
34
-
35
- The return value is a ProcStat structure and sets the $last_status global
36
- variable. The special global $? is also set. Raises a SystemError if there
37
- are no child processes.
38
-
39
- Proc.wait4(pid, flags=0)
40
- Waits for the given child process to exit. Returns a ProcStat structure.
41
- The $last_status global variable is set. Also sets the $? special global
42
- variable.
43
-
44
- Proc.waitid(id_type, id_num=nil, options=nil)
45
- Suspends the calling process until one of its children changes state,
46
- returning immediately if a child process changed state prior to the call.
47
- The state of a child process will change if it terminates, stops because
48
- of a signal, becomes trapped or reaches a breakpoint.
49
-
50
- The id_num corresponds to a process ID or process group ID, depending on
51
- the value of +id_type+, which may be Process::P_PID, Process::P_PGID or
52
- Process::P_ALL. If +id_type+ is Process::P_ALL, then the +id_num+ is ignored.
53
-
54
- The options argument is used to specify which state changes are to be
55
- waited for. It is constructed from the bitwise-OR of one or more of the
56
- following constants:
57
-
58
- Process::WCONTINUED
59
- Process::WEXITED
60
- Process::WNOHANG
61
- Process::WNOWAIT
62
- Process::WSTOPPED
63
- Process::WTRAPPED (not supported on all platforms)
64
-
65
- If Process::WNOHANG is set as an option, this method will return
66
- immediately, whether or not a child has changed state.
67
-
68
- Calling this method with an +id_type+ of Process::P_ALL and the options set
69
- to 'Process::EXITED | Process::WTRAPPED' is equivalent to calling
70
- Process.wait.
71
-
72
- Returns a Proc::SigInfo struct and sets $?.
73
-
74
- Not supported on all platforms.
75
-
76
- == Constants
77
- === Standard
78
- Process::WAIT3_VERSION
79
- Returns the version of this package as a string.
80
-
81
- === Process type constants
82
- ==== All platforms
83
- Process::P_ALL
84
- All non-system process.
85
-
86
- Process::P_PID
87
- A standard process id.
88
-
89
- Process::P_PGID
90
- Any non-system process group id.
91
-
92
- ==== Not supported on all platforms
93
- Process::P_CID
94
- A scheduler process id.
95
-
96
- Process::P_GID
97
- Any non-system effective process group id.
98
-
99
- Process::P_PROJID
100
- A project process id. Solaris 8 or later only.
101
-
102
- Process::P_SID
103
- A session process id.
104
-
105
- Process::P_TASKID
106
- A task process id. Solaris 8 or later only.
107
-
108
- Process::P_UID
109
- Any non-system effective process user id.
110
-
111
- === The following additional constants are defined if the waitid function is
112
- supported on your system.
113
-
114
- Process::WCONTINUED
115
- Return the status for any child that was stopped and has been continued.
116
-
117
- Process::WEXITED
118
- Wait for process(es) to exit.
119
-
120
- Process::WNOWAIT
121
- Keep the process in a waitable state.
122
-
123
- Process::WSTOPPED
124
- Wait for and return the process status of any child that has stopped upon
125
- receipt of a signal.
126
-
127
- Process::WTRAPPED
128
- Wait for traced process(es) to become trapped or reach a breakpoint.
129
-
130
- Not supported on all platforms.
131
-
132
- === RLIMIT constants
133
- Process::RLIMIT_AS
134
- A synonym for RLIMIT_VMEM
135
-
136
- Process::RLIMIT_CORE
137
- The maximum size of a core file, in bytes, that may be created.
138
-
139
- Process::RLIMIT_CPU
140
- The maximum amount of CPU time, in seconds, the process is allowed to use.
141
-
142
- Process::RLIMIT_DATA
143
- The maximum size of the process' heap size, in bytes.
144
-
145
- Process::RLIMIT_FSIZE
146
- The maximum size of a file, in bytes, that the process may create.
147
-
148
- Process::RLIMIT_NOFILE
149
- The maximum value that the kernel may assign to a file descriptor,
150
- effectively limiting the number of open files for the calling process.
151
-
152
- Process::RLIMIT_STACK
153
- The maximum size of the process' stack in bytes.
154
-
155
- Process::RLIMIT_VMEM
156
- The maximum size of the process' mapped address space.
157
-
158
- Process::RLIM_INFINITY
159
- A infinite limit.
160
-
161
- Process::RLIM_SAVED_CUR
162
- Current soft limit.
163
-
164
- Process::RLIM_SAVED_MAX
165
- Current hard limit.
166
-
167
- == Notes
168
- The wait3 and wait4 methods are similar to the wait2 and waitpid2
169
- methods, except that they return much more information via the rusage
170
- struct.
171
-
172
- == Known Bugs
173
- None that I'm aware of. Please log any bugs on the Github project
174
- page at https://github.com/djberg96/proc-wait3.
175
-
176
- == License
177
- Apache-2.0
178
-
179
- == Copyright
180
- (C) 2003-2019 Daniel J. Berger
181
- All Rights Reserved.
182
-
183
- == Warranty
184
- This package is provided "as is" and without any express or
185
- implied warranties, including, without limitation, the implied
186
- warranties of merchantability and fitness for a particular purpose.
187
-
188
- == Author
189
- Daniel J. Berger
190
-
191
- == See also
192
- wait3, wait4, waitid, pause, sigsend