proc-wait3 1.6.0 → 1.7.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.
- checksums.yaml +7 -0
- data/CHANGES +9 -0
- data/README +1 -2
- data/Rakefile +8 -3
- data/doc/wait3.txt +9 -18
- data/ext/extconf.rb +15 -1
- data/ext/proc/wait3.c +97 -85
- data/proc-wait3.gemspec +4 -5
- data/test/test_proc_wait3.rb +91 -109
- metadata +55 -56
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c48dfef5da3932850a5edfd6fc5dc1ccb710ede6
|
4
|
+
data.tar.gz: f861c07250bef10b844fb787839066659916cfc9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 79bb2aec93d32d8cbd1d22030e9fe8f684f38faacf3c0cb2ce79e4d3c30a710c863cbb017cfcfe94922612bbc6548c81c3f817683e50a8d0b44112328644653c
|
7
|
+
data.tar.gz: 55e6b2168f84b5115ab428264efeefb87cb1d0e1f301c6040af13fe8595f4b1f82fbfa9392f63180df0f5c0aec4cc26bc2f158d0936bbb2daeb497f5644cc58f
|
data/CHANGES
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
== 1.7.0 - 6-Apr-2014
|
2
|
+
* The wait3 and wait4 methods no longer set $? to a custom struct. The builtin
|
3
|
+
variable is still set, but if you need the custom Struct::ProcStat information
|
4
|
+
then use the $last_status global instead, or just use the return value. This
|
5
|
+
was changed thanks to an issue pointed out by Michael Lee Squires where
|
6
|
+
subsequent system calls no longer set $? properly.
|
7
|
+
* Some build warning fixes for BSD platforms.
|
8
|
+
* Some test updates for BSD and Solaris.
|
9
|
+
|
1
10
|
== 1.6.0 - 28-Aug-2011
|
2
11
|
* Removed the getrlimit and setrlimit methods. Ruby has supported these methods
|
3
12
|
since Ruby 1.8.5, so I think it's time to finally dump them.
|
data/README
CHANGED
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@ require 'rake/clean'
|
|
3
3
|
require 'rake/testtask'
|
4
4
|
require 'fileutils'
|
5
5
|
require 'rbconfig'
|
6
|
-
include
|
6
|
+
include RbConfig
|
7
7
|
|
8
8
|
CLEAN.include(
|
9
9
|
'**/*.gem', # Gem files
|
@@ -20,7 +20,7 @@ task :build => [:clean] do |t|
|
|
20
20
|
Dir.chdir('ext') do
|
21
21
|
ruby 'extconf.rb'
|
22
22
|
sh 'make'
|
23
|
-
FileUtils.mv 'wait3.' +
|
23
|
+
FileUtils.mv 'wait3.' + RbConfig::CONFIG['DLEXT'], 'proc'
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -28,7 +28,12 @@ namespace :gem do
|
|
28
28
|
desc "Create the proc-wait3 gem"
|
29
29
|
task :create => [:clean] do
|
30
30
|
spec = eval(IO.read('proc-wait3.gemspec'))
|
31
|
-
Gem::
|
31
|
+
if Gem::VERSION < "2.0"
|
32
|
+
Gem::Builder.new(spec).build
|
33
|
+
else
|
34
|
+
require 'rubygems/package'
|
35
|
+
Gem::Package.build(spec)
|
36
|
+
end
|
32
37
|
end
|
33
38
|
|
34
39
|
desc "Install the proc-wait3 gem"
|
data/doc/wait3.txt
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
== Description
|
2
2
|
Adds the wait3, wait4, waitid, pause, sigsend, and getrusage methods to
|
3
|
-
the Process module.
|
4
|
-
and setrlimit methods.
|
3
|
+
the Process module.
|
5
4
|
|
6
5
|
== Synopsis
|
7
6
|
require 'proc/wait3'
|
@@ -33,12 +32,14 @@ Proc.wait3(flags=0)
|
|
33
32
|
Delays its caller until a signal is received or one of its child processes
|
34
33
|
terminates or stops due to tracing.
|
35
34
|
|
36
|
-
The return value is a ProcStat structure
|
37
|
-
set. Raises a SystemError if there
|
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
38
|
|
39
39
|
Proc.wait4(pid, flags=0)
|
40
40
|
Waits for the given child process to exit. Returns a ProcStat structure.
|
41
|
-
Also sets the $? special global
|
41
|
+
The $last_status global variable is set. Also sets the $? special global
|
42
|
+
variable.
|
42
43
|
|
43
44
|
Proc.waitid(id_type, id_num=nil, options=nil)
|
44
45
|
Suspends the calling process until one of its children changes state,
|
@@ -72,16 +73,6 @@ Proc.waitid(id_type, id_num=nil, options=nil)
|
|
72
73
|
|
73
74
|
Not supported on all platforms.
|
74
75
|
|
75
|
-
== Ruby 1.8.4 or earlier.
|
76
|
-
Process.getrlimit(resource) => [cur_limit, max_limit]
|
77
|
-
Returns a two element array consisting of the hard and soft limit
|
78
|
-
for the current process for the given +resource+. The array consists of
|
79
|
-
either numeric values or the word "infinite".
|
80
|
-
|
81
|
-
Process.setrlimit(resource, current, max=nil) => nil
|
82
|
-
Sets the resource limit for +resource+ to +current+ for the soft limit and
|
83
|
-
+max+ for the hard limit, or to +current+ if +max+ is nil.
|
84
|
-
|
85
76
|
== Constants
|
86
77
|
=== Standard
|
87
78
|
Process::WAIT3_VERSION
|
@@ -179,14 +170,14 @@ Process::RLIM_SAVED_MAX
|
|
179
170
|
struct.
|
180
171
|
|
181
172
|
== Known Bugs
|
182
|
-
None that I'm aware of. Please log any bugs on the
|
183
|
-
page at
|
173
|
+
None that I'm aware of. Please log any bugs on the Github project
|
174
|
+
page at https://github.com/djberg96/proc-wait3.
|
184
175
|
|
185
176
|
== License
|
186
177
|
Artistic 2.0
|
187
178
|
|
188
179
|
== Copyright
|
189
|
-
(C) 2003-
|
180
|
+
(C) 2003-2014 Daniel J. Berger
|
190
181
|
All Rights Reserved.
|
191
182
|
|
192
183
|
== Warranty
|
data/ext/extconf.rb
CHANGED
@@ -44,6 +44,7 @@ have_func('strlcpy')
|
|
44
44
|
# wait4, waitid, etc, are optional (HPUX, et al)
|
45
45
|
have_func('wait4')
|
46
46
|
have_func('waitid')
|
47
|
+
have_func('sigset')
|
47
48
|
have_func('sigsend')
|
48
49
|
have_func('getrusage')
|
49
50
|
have_func('getdtablesize')
|
@@ -64,7 +65,20 @@ have_struct_member('struct siginfo', 'si_stime', 'signal.h')
|
|
64
65
|
|
65
66
|
have_const('P_CID', 'signal.h')
|
66
67
|
have_const('P_GID', 'signal.h')
|
67
|
-
have_const('P_MYID', 'signal.
|
68
|
+
have_const('P_MYID', 'signal.hclass PasswdStruct < FFI::Struct
|
69
|
+
layout(
|
70
|
+
:pw_name, :string,
|
71
|
+
:pw_passwd, :string,
|
72
|
+
:pw_uid, :uint,
|
73
|
+
:pw_gid, :uint,
|
74
|
+
:pw_change, :ulong,
|
75
|
+
:pw_class, :string,
|
76
|
+
:pw_gecos, :string,
|
77
|
+
:pw_dir, :string,
|
78
|
+
:pw_shell, :string,
|
79
|
+
:pw_expire, :ulong
|
80
|
+
)
|
81
|
+
end')
|
68
82
|
have_const('P_SID', 'signal.h')
|
69
83
|
have_const('P_UID', 'signal.h')
|
70
84
|
|
data/ext/proc/wait3.c
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
#include <sys/wait.h>
|
10
10
|
#endif
|
11
11
|
|
12
|
-
#
|
12
|
+
#if defined(HAVE_WAITID) || defined(HAVE_SIGSET)
|
13
13
|
#include <signal.h>
|
14
14
|
#endif
|
15
15
|
|
@@ -65,10 +65,10 @@ static VALUE pst_wifstopped(int status)
|
|
65
65
|
*/
|
66
66
|
static VALUE pst_wifsignaled(int status)
|
67
67
|
{
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
68
|
+
if (WIFSIGNALED(status))
|
69
|
+
return Qtrue;
|
70
|
+
else
|
71
|
+
return Qfalse;
|
72
72
|
}
|
73
73
|
|
74
74
|
/*
|
@@ -77,10 +77,10 @@ static VALUE pst_wifsignaled(int status)
|
|
77
77
|
*/
|
78
78
|
static VALUE pst_wifexited(int status)
|
79
79
|
{
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
80
|
+
if (WIFEXITED(status))
|
81
|
+
return Qtrue;
|
82
|
+
else
|
83
|
+
return Qfalse;
|
84
84
|
}
|
85
85
|
|
86
86
|
/*
|
@@ -89,9 +89,10 @@ static VALUE pst_wifexited(int status)
|
|
89
89
|
*/
|
90
90
|
static VALUE pst_success_p(int status)
|
91
91
|
{
|
92
|
-
|
93
|
-
|
94
|
-
|
92
|
+
if (!WIFEXITED(status))
|
93
|
+
return Qnil;
|
94
|
+
|
95
|
+
return WEXITSTATUS(status) == EXIT_SUCCESS ? Qtrue : Qfalse;
|
95
96
|
}
|
96
97
|
|
97
98
|
/*
|
@@ -101,12 +102,12 @@ static VALUE pst_success_p(int status)
|
|
101
102
|
static VALUE pst_wcoredump(int status)
|
102
103
|
{
|
103
104
|
#ifdef WCOREDUMP
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
105
|
+
if (WCOREDUMP(status))
|
106
|
+
return Qtrue;
|
107
|
+
else
|
108
|
+
return Qfalse;
|
108
109
|
#else
|
109
|
-
|
110
|
+
return Qfalse;
|
110
111
|
#endif
|
111
112
|
}
|
112
113
|
|
@@ -116,9 +117,10 @@ static VALUE pst_wcoredump(int status)
|
|
116
117
|
*/
|
117
118
|
static VALUE pst_wexitstatus(int status)
|
118
119
|
{
|
119
|
-
|
120
|
-
|
121
|
-
|
120
|
+
if (WIFEXITED(status))
|
121
|
+
return INT2NUM(WEXITSTATUS(status));
|
122
|
+
|
123
|
+
return Qnil;
|
122
124
|
}
|
123
125
|
|
124
126
|
/*
|
@@ -127,9 +129,10 @@ static VALUE pst_wexitstatus(int status)
|
|
127
129
|
*/
|
128
130
|
static VALUE pst_wtermsig(int status)
|
129
131
|
{
|
130
|
-
|
131
|
-
|
132
|
-
|
132
|
+
if (WIFSIGNALED(status))
|
133
|
+
return INT2NUM(WTERMSIG(status));
|
134
|
+
|
135
|
+
return Qnil;
|
133
136
|
}
|
134
137
|
|
135
138
|
/*
|
@@ -138,9 +141,10 @@ static VALUE pst_wtermsig(int status)
|
|
138
141
|
*/
|
139
142
|
static VALUE pst_wstopsig(int status)
|
140
143
|
{
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
+
if(WIFSTOPPED(status))
|
145
|
+
return INT2NUM(WSTOPSIG(status));
|
146
|
+
|
147
|
+
return Qnil;
|
144
148
|
}
|
145
149
|
|
146
150
|
/*
|
@@ -200,6 +204,10 @@ static VALUE proc_wait3(int argc, VALUE *argv, VALUE mod){
|
|
200
204
|
pst_wtermsig(status),
|
201
205
|
pst_wstopsig(status)
|
202
206
|
);
|
207
|
+
|
208
|
+
rb_last_status_set(status, pid);
|
209
|
+
OBJ_FREEZE(v_last_status);
|
210
|
+
|
203
211
|
return v_last_status;
|
204
212
|
}
|
205
213
|
else{
|
@@ -268,6 +276,10 @@ static VALUE proc_wait4(int argc, VALUE *argv, VALUE mod){
|
|
268
276
|
pst_wtermsig(status),
|
269
277
|
pst_wstopsig(status)
|
270
278
|
);
|
279
|
+
|
280
|
+
rb_last_status_set(status, pid);
|
281
|
+
OBJ_FREEZE(v_last_status);
|
282
|
+
|
271
283
|
return v_last_status;
|
272
284
|
}
|
273
285
|
else{
|
@@ -670,36 +682,36 @@ static void sigproc(int signum){ /* Do nothing */ }
|
|
670
682
|
* Any non-system process whose effective user ID is equal to +id+.
|
671
683
|
*/
|
672
684
|
static VALUE proc_sigsend(int argc, VALUE* argv, VALUE mod){
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
685
|
+
VALUE v_type, v_pid, v_signal;
|
686
|
+
idtype_t idtype;
|
687
|
+
id_t id;
|
688
|
+
int sig = 0; /* 0 is our default signal (i.e. no signal) */
|
677
689
|
|
678
|
-
|
690
|
+
rb_scan_args(argc, argv, "21", &v_type, &v_pid, &v_signal);
|
679
691
|
|
680
|
-
|
681
|
-
|
692
|
+
idtype = NUM2INT(v_type);
|
693
|
+
id = NUM2INT(v_pid);
|
682
694
|
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
695
|
+
if(!NIL_P(v_signal)){
|
696
|
+
if(TYPE(v_signal) == T_FIXNUM){
|
697
|
+
sig = FIX2INT(v_signal);
|
698
|
+
}
|
699
|
+
else{
|
700
|
+
char signame[SIG2STR_MAX];
|
701
|
+
unsigned int max = SIG2STR_MAX;
|
690
702
|
|
691
|
-
|
692
|
-
|
703
|
+
if(strlcpy(signame, StringValuePtr(v_signal), max) >= max)
|
704
|
+
rb_raise(rb_eArgError, "string too large");
|
693
705
|
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
706
|
+
if(str2sig(signame,&sig) != 0)
|
707
|
+
rb_sys_fail("str2sig");
|
708
|
+
}
|
709
|
+
}
|
698
710
|
|
699
|
-
|
700
|
-
|
711
|
+
if(sigsend(idtype,id,sig) != 0)
|
712
|
+
rb_sys_fail("sigsend");
|
701
713
|
|
702
|
-
|
714
|
+
return Qnil;
|
703
715
|
}
|
704
716
|
#endif
|
705
717
|
|
@@ -709,8 +721,8 @@ static VALUE proc_sigsend(int argc, VALUE* argv, VALUE mod){
|
|
709
721
|
* Process.getrusage(children=false)
|
710
722
|
*
|
711
723
|
* Returns comprehensive process resource usage information in the form of a
|
712
|
-
* RUsage struct.
|
713
|
-
* process.
|
724
|
+
* RUsage struct. By default, this will return information for the current
|
725
|
+
* process. If +children+ is set to true, it will return information for
|
714
726
|
* terminated and waited for children of the current process.
|
715
727
|
*
|
716
728
|
* The RUsage struct contains the following members:
|
@@ -735,36 +747,36 @@ static VALUE proc_sigsend(int argc, VALUE* argv, VALUE mod){
|
|
735
747
|
* Note that not all members contain meaningful values on all platforms.
|
736
748
|
*/
|
737
749
|
static VALUE proc_getrusage(int argc, VALUE* argv, VALUE mod){
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
750
|
+
VALUE v_children = Qfalse;
|
751
|
+
struct rusage r;
|
752
|
+
int who = RUSAGE_SELF;
|
753
|
+
|
754
|
+
rb_scan_args(argc, argv, "01", &v_children);
|
755
|
+
|
756
|
+
if(RTEST(v_children))
|
757
|
+
who = RUSAGE_CHILDREN;
|
758
|
+
|
759
|
+
if(getrusage(who,&r) == -1)
|
760
|
+
rb_sys_fail("getrusage");
|
761
|
+
|
762
|
+
return rb_struct_new(v_usage_struct,
|
763
|
+
rb_float_new((double)r.ru_utime.tv_sec+(double)r.ru_utime.tv_usec/1e6),
|
764
|
+
rb_float_new((double)r.ru_stime.tv_sec+(double)r.ru_stime.tv_usec/1e6),
|
765
|
+
LONG2NUM(r.ru_maxrss),
|
766
|
+
LONG2NUM(r.ru_ixrss),
|
767
|
+
LONG2NUM(r.ru_idrss),
|
768
|
+
LONG2NUM(r.ru_isrss),
|
769
|
+
LONG2NUM(r.ru_minflt),
|
770
|
+
LONG2NUM(r.ru_majflt),
|
771
|
+
LONG2NUM(r.ru_nswap),
|
772
|
+
LONG2NUM(r.ru_inblock),
|
773
|
+
LONG2NUM(r.ru_oublock),
|
774
|
+
LONG2NUM(r.ru_msgsnd),
|
775
|
+
LONG2NUM(r.ru_msgrcv),
|
776
|
+
LONG2NUM(r.ru_nsignals),
|
777
|
+
LONG2NUM(r.ru_nvcsw),
|
778
|
+
LONG2NUM(r.ru_nivcsw)
|
779
|
+
);
|
768
780
|
}
|
769
781
|
#endif
|
770
782
|
|
@@ -778,7 +790,7 @@ static VALUE proc_getrusage(int argc, VALUE* argv, VALUE mod){
|
|
778
790
|
* as the resource identifier.
|
779
791
|
*/
|
780
792
|
static VALUE proc_getdtablesize(VALUE mod){
|
781
|
-
|
793
|
+
return INT2FIX(getdtablesize());
|
782
794
|
}
|
783
795
|
#endif
|
784
796
|
|
@@ -949,9 +961,9 @@ void Init_wait3()
|
|
949
961
|
rb_define_const(rb_mProcess, "P_PROJID", INT2FIX(P_PROJID));
|
950
962
|
#endif
|
951
963
|
|
952
|
-
/* 1.
|
953
|
-
rb_define_const(rb_mProcess, "WAIT3_VERSION", rb_str_new2("1.
|
964
|
+
/* 1.7.0: The version of the proc-wait3 library */
|
965
|
+
rb_define_const(rb_mProcess, "WAIT3_VERSION", rb_str_new2("1.7.0"));
|
954
966
|
|
955
967
|
/* Define this last in our Init_wait3 function */
|
956
|
-
rb_define_readonly_variable("
|
968
|
+
rb_define_readonly_variable("$last_status", &v_last_status);
|
957
969
|
}
|
data/proc-wait3.gemspec
CHANGED
@@ -2,21 +2,20 @@ require 'rubygems'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'proc-wait3'
|
5
|
-
spec.version = '1.
|
5
|
+
spec.version = '1.7.0'
|
6
6
|
spec.author = 'Daniel J. Berger'
|
7
7
|
spec.license = 'Artistic 2.0'
|
8
8
|
spec.email = 'djberg96@gmail.com'
|
9
|
-
spec.homepage = '
|
10
|
-
spec.platform = Gem::Platform::RUBY
|
9
|
+
spec.homepage = 'https://github.com/djberg96/proc-wait3'
|
11
10
|
spec.summary = 'Adds wait3, wait4 and other methods to the Process module'
|
12
11
|
spec.test_file = 'test/test_proc_wait3.rb'
|
13
12
|
spec.extensions = ['ext/extconf.rb']
|
14
13
|
spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
|
15
14
|
|
16
|
-
spec.rubyforge_project = 'shards'
|
17
15
|
spec.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST', 'ext/proc/wait3.c']
|
18
16
|
|
19
|
-
spec.add_development_dependency('test-unit'
|
17
|
+
spec.add_development_dependency('test-unit')
|
18
|
+
spec.add_development_dependency('rake')
|
20
19
|
|
21
20
|
spec.description = <<-EOF
|
22
21
|
The proc-wait3 library adds the wait3, wait4, waitid, pause, sigsend,
|
data/test/test_proc_wait3.rb
CHANGED
@@ -4,21 +4,17 @@
|
|
4
4
|
# Test suite for the Ruby proc-wait3 package. You should run this
|
5
5
|
# via the 'test' rake task.
|
6
6
|
##################################################################
|
7
|
-
require 'rubygems'
|
8
|
-
gem 'test-unit'
|
9
|
-
|
10
7
|
require 'proc/wait3'
|
11
|
-
require 'test
|
8
|
+
require 'test-unit'
|
12
9
|
require 'rbconfig'
|
13
10
|
|
14
|
-
class TC_Proc_Wait3 < Test::Unit::TestCase
|
11
|
+
class TC_Proc_Wait3 < Test::Unit::TestCase
|
15
12
|
def self.startup
|
16
|
-
@@solaris =
|
17
|
-
@@darwin =
|
18
|
-
@@hpux =
|
19
|
-
@@linux =
|
20
|
-
@@freebsd =
|
21
|
-
@@old_ruby = RUBY_VERSION.split('.').last.to_i < 5
|
13
|
+
@@solaris = RbConfig::CONFIG['host_os'] =~ /sunos|solaris/i
|
14
|
+
@@darwin = RbConfig::CONFIG['host_os'] =~ /darwin|osx/i
|
15
|
+
@@hpux = RbConfig::CONFIG['host_os'] =~ /hpux/i
|
16
|
+
@@linux = RbConfig::CONFIG['host_os'] =~ /linux/i
|
17
|
+
@@freebsd = RbConfig::CONFIG['host_os'] =~ /bsd/i
|
22
18
|
end
|
23
19
|
|
24
20
|
def setup
|
@@ -36,31 +32,50 @@ class TC_Proc_Wait3 < Test::Unit::TestCase
|
|
36
32
|
end
|
37
33
|
end
|
38
34
|
|
39
|
-
|
40
|
-
assert_equal('1.
|
35
|
+
test "version constant is set to expected value" do
|
36
|
+
assert_equal('1.7.0', Process::WAIT3_VERSION)
|
41
37
|
end
|
42
38
|
|
43
|
-
|
39
|
+
test "wait3 method is defined" do
|
44
40
|
assert_respond_to(Process, :wait3)
|
45
41
|
end
|
46
42
|
|
47
|
-
|
48
|
-
|
43
|
+
test "wait3 works as expected" do
|
44
|
+
fork{ sleep 0.5 }
|
49
45
|
assert_nothing_raised{ Process.wait3 }
|
50
46
|
end
|
51
47
|
|
52
|
-
|
53
|
-
|
48
|
+
test "wait3 returns the expected proc status membes" do
|
49
|
+
fork{ sleep 0.5 }
|
54
50
|
assert_nothing_raised{ @proc_stat = Process.wait3 }
|
55
51
|
assert_equal(@proc_stat_members, @proc_stat.members)
|
56
52
|
end
|
57
53
|
|
58
|
-
|
59
|
-
|
54
|
+
test "wait3 with WNOHANG works as expected" do
|
55
|
+
fork{ sleep 0.5 }
|
60
56
|
assert_nothing_raised{ Process.wait3(Process::WNOHANG) }
|
61
57
|
end
|
62
58
|
|
63
|
-
|
59
|
+
test "wait3 sets and returns $last_status to expected values" do
|
60
|
+
fork{ sleep 0.5 }
|
61
|
+
Process.wait3
|
62
|
+
assert_kind_of(Struct::ProcStat, $last_status)
|
63
|
+
assert_not_nil($last_status)
|
64
|
+
end
|
65
|
+
|
66
|
+
test "wait3 sets pid and status members of $?" do
|
67
|
+
fork{ sleep 0.5 }
|
68
|
+
Process.wait3
|
69
|
+
assert_not_nil($?)
|
70
|
+
end
|
71
|
+
|
72
|
+
test "wait3 returns frozen struct" do
|
73
|
+
fork{ sleep 0.5 }
|
74
|
+
struct = Process.wait3
|
75
|
+
assert_true(struct.frozen?)
|
76
|
+
end
|
77
|
+
|
78
|
+
test "getdtablesize works as expected" do
|
64
79
|
omit_unless(@@solaris, 'getdtablesize skipped on this platform')
|
65
80
|
|
66
81
|
assert_respond_to(Process, :getdtablesize)
|
@@ -68,74 +83,100 @@ class TC_Proc_Wait3 < Test::Unit::TestCase
|
|
68
83
|
assert(Process.getdtablesize > 0)
|
69
84
|
end
|
70
85
|
|
71
|
-
|
86
|
+
test "wait4 method is defined" do
|
72
87
|
omit_if(@@hpux, 'wait4 test skipped on this platform')
|
73
|
-
|
74
88
|
assert_respond_to(Process,:wait4)
|
75
|
-
assert_raises(ArgumentError){ Process.wait4 } # Must have at least 1 arg
|
76
89
|
end
|
77
90
|
|
78
|
-
|
91
|
+
test "wait4 requires at least one argument" do
|
92
|
+
assert_raises(ArgumentError){ Process.wait4 }
|
93
|
+
end
|
94
|
+
|
95
|
+
test "wait4 works as expected" do
|
79
96
|
omit_if(@@hpux, 'wait4 test skipped on this platform')
|
80
97
|
|
81
|
-
pid = fork{ sleep
|
82
|
-
assert_nothing_raised{ @proc_stat = Process.wait4(pid) }
|
98
|
+
pid = fork{ sleep 0.5 }
|
99
|
+
assert_nothing_raised{ @proc_stat = Process.wait4(pid) }
|
83
100
|
assert_kind_of(Struct::ProcStat, @proc_stat)
|
84
101
|
end
|
85
102
|
|
86
|
-
|
87
|
-
|
103
|
+
test "wait4 sets and returns $last_status to expected values" do
|
104
|
+
pid = fork{ sleep 0.5 }
|
105
|
+
Process.wait4(pid)
|
106
|
+
assert_kind_of(Struct::ProcStat, $last_status)
|
107
|
+
assert_not_nil($last_status)
|
108
|
+
end
|
88
109
|
|
89
|
-
|
110
|
+
test "wait4 sets pid and status members of $?" do
|
111
|
+
pid = fork{ sleep 0.5 }
|
112
|
+
Process.wait4(pid)
|
113
|
+
assert_not_nil($?)
|
114
|
+
end
|
115
|
+
|
116
|
+
test "wait4 returns frozen struct" do
|
117
|
+
pid = fork{ sleep 0.5 }
|
118
|
+
struct = Process.wait4(pid)
|
119
|
+
assert_true(struct.frozen?)
|
90
120
|
end
|
91
121
|
|
92
|
-
|
122
|
+
test "waitid method is defined" do
|
93
123
|
omit_if(@@hpux || @@darwin || @@freebsd, 'waitid test skipped on this platform')
|
94
|
-
|
124
|
+
assert_respond_to(Process, :waitid)
|
125
|
+
end
|
95
126
|
|
127
|
+
test "waitid method works as expected" do
|
128
|
+
omit_if(@@hpux || @@darwin || @@freebsd, 'waitid test skipped on this platform')
|
129
|
+
pid = fork{ sleep 0.5 }
|
96
130
|
assert_nothing_raised{ Process.waitid(Process::P_PID, pid, Process::WEXITED) }
|
97
131
|
end
|
98
132
|
|
99
|
-
|
133
|
+
test "waitid method raises expected errors if wrong argument type is passed" do
|
100
134
|
omit_if(@@hpux || @@darwin || @@freebsd, 'waitid test skipped on this platform')
|
101
|
-
pid = fork{ sleep
|
102
|
-
|
135
|
+
pid = fork{ sleep 0.5 }
|
103
136
|
assert_raises(TypeError){ Process.waitid("foo", pid, Process::WEXITED) }
|
104
137
|
assert_raises(TypeError){ Process.waitid(Process::P_PID, pid, "foo") }
|
105
138
|
assert_raises(TypeError){ Process.waitid(Process::P_PID, "foo", Process::WEXITED) }
|
139
|
+
end
|
140
|
+
|
141
|
+
test "waitid method raises expected error if invalid argument is passed" do
|
142
|
+
omit_if(@@hpux || @@darwin || @@freebsd, 'waitid test skipped on this platform')
|
143
|
+
fork{ sleep 0.5 }
|
106
144
|
assert_raises(Errno::ECHILD, Errno::EINVAL){ Process.waitid(Process::P_PID, 99999999, Process::WEXITED) }
|
107
145
|
end
|
108
146
|
|
109
|
-
|
147
|
+
test "sigsend method is defined" do
|
110
148
|
omit_unless(@@solaris, 'sigsend test skipped on this platform')
|
111
149
|
assert_respond_to(Process, :sigsend)
|
112
150
|
end
|
113
151
|
|
114
|
-
|
152
|
+
test "sigsend works as expected" do
|
115
153
|
omit_unless(@@solaris, 'sigsend test skipped on this platform')
|
116
|
-
pid = fork{ sleep
|
117
|
-
|
154
|
+
pid = fork{ sleep 0.5 }
|
118
155
|
assert_nothing_raised{ Process.sigsend(Process::P_PID, pid, 0) }
|
119
156
|
end
|
120
157
|
|
121
|
-
|
158
|
+
test "getrusage method is defined" do
|
122
159
|
assert_respond_to(Process, :getrusage)
|
123
160
|
end
|
124
161
|
|
125
|
-
|
126
|
-
|
162
|
+
test "getrusage works as expected" do
|
163
|
+
fork{ sleep 0.5 }
|
127
164
|
assert_nothing_raised{ Process.getrusage }
|
128
165
|
assert_nothing_raised{ Process.getrusage(true) }
|
166
|
+
end
|
167
|
+
|
168
|
+
test "getrusage returns the expected struct" do
|
169
|
+
fork{ sleep 0.5 }
|
129
170
|
assert_kind_of(Struct::RUsage, Process.getrusage)
|
130
171
|
assert_kind_of(Float, Process.getrusage.stime)
|
131
172
|
assert_kind_of(Float, Process.getrusage.utime)
|
132
173
|
end
|
133
174
|
|
134
|
-
|
175
|
+
test "pause method is defined" do
|
135
176
|
assert_respond_to(Process, :pause)
|
136
177
|
end
|
137
178
|
|
138
|
-
|
179
|
+
test "expected constants are defined" do
|
139
180
|
omit_if(@@darwin || @@freebsd, 'wait constant check skipped on this platform')
|
140
181
|
|
141
182
|
assert_not_nil(Process::WCONTINUED)
|
@@ -147,78 +188,20 @@ class TC_Proc_Wait3 < Test::Unit::TestCase
|
|
147
188
|
assert_not_nil(Process::WTRAPPED)
|
148
189
|
end
|
149
190
|
|
150
|
-
|
151
|
-
omit_unless(@@old_ruby, 'getrlimit test skipped on recent versions of Ruby')
|
152
|
-
|
153
|
-
assert_respond_to(Process, :getrlimit)
|
154
|
-
assert_nothing_raised{ Process.getrlimit(Process::RLIMIT_CPU) }
|
155
|
-
assert_kind_of(Array, Process.getrlimit(Process::RLIMIT_CPU))
|
156
|
-
assert_equal(2, Process.getrlimit(Process::RLIMIT_CPU).length)
|
157
|
-
end
|
158
|
-
|
159
|
-
def test_setrlimit
|
160
|
-
omit_unless(@@old_ruby, 'setrlimit test skipped on recent versions of Ruby')
|
161
|
-
|
162
|
-
assert_respond_to(Process, :setrlimit)
|
163
|
-
assert_nothing_raised{
|
164
|
-
Process.setrlimit(
|
165
|
-
Process::RLIMIT_CPU,
|
166
|
-
Process::RLIM_SAVED_CUR,
|
167
|
-
Process::RLIM_SAVED_MAX
|
168
|
-
)
|
169
|
-
}
|
170
|
-
|
171
|
-
assert_nothing_raised{
|
172
|
-
Process.setrlimit(Process::RLIMIT_CPU, Process::RLIM_SAVED_CUR)
|
173
|
-
}
|
174
|
-
end
|
175
|
-
|
176
|
-
# Test to ensure that the various rlimit constants are defined. Note that
|
177
|
-
# as of Ruby 1.8.5 these are defined by Ruby itself, except for the
|
178
|
-
# RLIMIT_VMEM constant, which is platform dependent.
|
179
|
-
#
|
180
|
-
def test_rlimit_constants
|
181
|
-
assert_not_nil(Process::RLIMIT_AS)
|
182
|
-
assert_not_nil(Process::RLIMIT_CORE)
|
183
|
-
assert_not_nil(Process::RLIMIT_CPU)
|
184
|
-
assert_not_nil(Process::RLIMIT_DATA)
|
185
|
-
assert_not_nil(Process::RLIMIT_FSIZE)
|
186
|
-
assert_not_nil(Process::RLIMIT_NOFILE)
|
187
|
-
assert_not_nil(Process::RLIMIT_STACK)
|
188
|
-
assert_not_nil(Process::RLIM_INFINITY)
|
189
|
-
end
|
190
|
-
|
191
|
-
def test_nonstandard_rlimit_constants
|
192
|
-
omit_unless(@@old_ruby, 'nonstandard rlimit constant tests skipped on recent versions of Ruby')
|
193
|
-
assert_not_nil(Process::RLIM_SAVED_MAX)
|
194
|
-
assert_not_nil(Process::RLIM_SAVED_CUR)
|
195
|
-
end
|
196
|
-
|
197
|
-
# This test was added to ensure that these three constants are being
|
198
|
-
# defined properly after an issue appeared on Linux with regards to
|
199
|
-
# the value accidentally being assigned a negative value.
|
200
|
-
#
|
201
|
-
def test_rlimit_constants_valid
|
202
|
-
omit_unless(@@old_ruby, 'valid rlimit constant tests skipped on recent versions of Ruby')
|
203
|
-
assert(Process::RLIM_INFINITY > 0)
|
204
|
-
assert(Process::RLIM_SAVED_MAX > 0)
|
205
|
-
assert(Process::RLIM_SAVED_CUR > 0)
|
206
|
-
end
|
207
|
-
|
208
|
-
def test_process_type_flags
|
191
|
+
test "expected process type flag constants are defined" do
|
209
192
|
omit_if(@@linux || @@darwin || @@freebsd, 'process type flag check skipped on this platform')
|
210
193
|
|
211
194
|
assert_not_nil(Process::P_ALL)
|
212
195
|
assert_not_nil(Process::P_CID)
|
213
196
|
assert_not_nil(Process::P_GID)
|
214
|
-
assert_not_nil(Process::P_MYID)
|
197
|
+
assert_not_nil(Process::P_MYID) unless @@solaris
|
215
198
|
assert_not_nil(Process::P_PGID)
|
216
|
-
assert_not_nil(Process::P_PID)
|
217
|
-
assert_not_nil(Process::P_SID)
|
199
|
+
assert_not_nil(Process::P_PID)
|
200
|
+
assert_not_nil(Process::P_SID)
|
218
201
|
assert_not_nil(Process::P_UID)
|
219
202
|
end
|
220
203
|
|
221
|
-
|
204
|
+
test "solaris-specific process type flags are defined on solaris" do
|
222
205
|
omit_unless(@@solaris, 'P_TASKID and P_PROJID constant check skipped on this platform')
|
223
206
|
|
224
207
|
assert_not_nil(Process::P_TASKID)
|
@@ -236,6 +219,5 @@ class TC_Proc_Wait3 < Test::Unit::TestCase
|
|
236
219
|
@@hpux = nil
|
237
220
|
@@linux = nil
|
238
221
|
@@freebsd = nil
|
239
|
-
@@old_ruby = nil
|
240
222
|
end
|
241
|
-
end
|
223
|
+
end
|
metadata
CHANGED
@@ -1,50 +1,60 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: proc-wait3
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 1
|
7
|
-
- 6
|
8
|
-
- 0
|
9
|
-
version: 1.6.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.7.0
|
10
5
|
platform: ruby
|
11
|
-
authors:
|
6
|
+
authors:
|
12
7
|
- Daniel J. Berger
|
13
8
|
autorequire:
|
14
9
|
bindir: bin
|
15
10
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2014-04-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
21
14
|
name: test-unit
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
22
21
|
prerelease: false
|
23
|
-
|
24
|
-
|
25
|
-
requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
26
24
|
- - ">="
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
33
34
|
type: :development
|
34
|
-
|
35
|
-
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: |2
|
42
|
+
The proc-wait3 library adds the wait3, wait4, waitid, pause, sigsend,
|
43
|
+
and getrusage methods to the Process module.
|
36
44
|
email: djberg96@gmail.com
|
37
45
|
executables: []
|
38
|
-
|
39
|
-
extensions:
|
46
|
+
extensions:
|
40
47
|
- ext/extconf.rb
|
41
|
-
extra_rdoc_files:
|
48
|
+
extra_rdoc_files:
|
42
49
|
- CHANGES
|
43
50
|
- README
|
44
51
|
- MANIFEST
|
45
52
|
- ext/proc/wait3.c
|
46
|
-
files:
|
53
|
+
files:
|
47
54
|
- CHANGES
|
55
|
+
- MANIFEST
|
56
|
+
- README
|
57
|
+
- Rakefile
|
48
58
|
- doc/wait3.txt
|
49
59
|
- examples/example_getrusage.rb
|
50
60
|
- examples/example_pause.rb
|
@@ -53,42 +63,31 @@ files:
|
|
53
63
|
- examples/example_waitid.rb
|
54
64
|
- ext/extconf.rb
|
55
65
|
- ext/proc/wait3.c
|
56
|
-
- MANIFEST
|
57
66
|
- proc-wait3.gemspec
|
58
|
-
- Rakefile
|
59
|
-
- README
|
60
67
|
- test/test_proc_wait3.rb
|
61
|
-
|
62
|
-
|
63
|
-
licenses:
|
68
|
+
homepage: https://github.com/djberg96/proc-wait3
|
69
|
+
licenses:
|
64
70
|
- Artistic 2.0
|
71
|
+
metadata: {}
|
65
72
|
post_install_message:
|
66
73
|
rdoc_options: []
|
67
|
-
|
68
|
-
require_paths:
|
74
|
+
require_paths:
|
69
75
|
- lib
|
70
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
-
|
72
|
-
requirements:
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
73
78
|
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
-
none: false
|
80
|
-
requirements:
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
81
83
|
- - ">="
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
|
84
|
-
- 0
|
85
|
-
version: "0"
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
86
|
requirements: []
|
87
|
-
|
88
|
-
|
89
|
-
rubygems_version: 1.3.7
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 2.2.2
|
90
89
|
signing_key:
|
91
|
-
specification_version:
|
90
|
+
specification_version: 4
|
92
91
|
summary: Adds wait3, wait4 and other methods to the Process module
|
93
|
-
test_files:
|
92
|
+
test_files:
|
94
93
|
- test/test_proc_wait3.rb
|