proc-wait3 1.5.3 → 1.5.4
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.
- data/CHANGES +11 -0
- data/MANIFEST +14 -0
- data/doc/wait3.txt +13 -13
- data/ext/extconf.rb +114 -0
- data/{lib → ext}/proc/wait3.c +43 -3
- data/test/tc_wait3.rb +47 -49
- metadata +46 -36
- data/extconf.rb +0 -78
data/CHANGES
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
== 1.5.4 - 7-Feb-2008
|
2
|
+
* ALERT! ALERT! Now auto-patches your mkmf.rb file to add the 'have_const'
|
3
|
+
method if it's not already found. This is necessary to determine if certain
|
4
|
+
enum values exist on your system. Your original mkmf.rb is backed up first
|
5
|
+
in case you ever need to restore it.
|
6
|
+
* Added lots of rdoc comments for the various constant values.
|
7
|
+
* Internal directory structure changes.
|
8
|
+
* Minor tweaks to the Rakefile and gem spec.
|
9
|
+
* Fixed the extconf.rb file so that it sets the target directory properly.
|
10
|
+
* No source code changes (except for comment updates and a version bump).
|
11
|
+
|
1
12
|
== 1.5.3 - 25-Oct-2006
|
2
13
|
* Because not all platforms support automatically converting signal names
|
3
14
|
into their equivalent numbers, the Process.pause method now accepts names
|
data/MANIFEST
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
CHANGES
|
2
|
+
MANIFEST
|
3
|
+
Rakefile
|
4
|
+
README
|
5
|
+
proc-wait3.gemspec
|
6
|
+
doc/wait3.txt
|
7
|
+
ext/extconf.rb
|
8
|
+
ext/proc/wait3.c
|
9
|
+
examples/test_getrusage.rb
|
10
|
+
examples/test_pause.rb
|
11
|
+
examples/test_wait3.rb
|
12
|
+
examples/test_wait4.rb
|
13
|
+
examples/test_waitid.rb
|
14
|
+
test/tc_wait3.rb
|
data/doc/wait3.txt
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
and setrlimit methods.
|
5
5
|
|
6
6
|
== Synopsis
|
7
|
-
require
|
7
|
+
require 'proc/wait3'
|
8
8
|
|
9
9
|
pid = fork{ sleep 1; exit 2 }
|
10
10
|
p Time.now
|
@@ -23,7 +23,7 @@ Proc.pause(signals=nil)
|
|
23
23
|
Returns the result of the pause() function, which should always be -1.
|
24
24
|
|
25
25
|
Process.sigsend(idtype, id, signal=0)
|
26
|
-
Sends a signal of type "idtype" to a process or process group "id".
|
26
|
+
Sends a signal of type "idtype" to a process or process group "id". This
|
27
27
|
is more versatile method of sending signals to processes than Process.kill.
|
28
28
|
|
29
29
|
For a list of valid idtype values, see the "Process type constants" below.
|
@@ -33,11 +33,11 @@ Proc.wait3(flags=0)
|
|
33
33
|
Delays its caller until a signal is received or one of its child processes
|
34
34
|
terminates or stops due to tracing.
|
35
35
|
|
36
|
-
The return value is a ProcStat structure.
|
37
|
-
set.
|
36
|
+
The return value is a ProcStat structure. The special global $? is also
|
37
|
+
set. Raises a SystemError if there are no child processes.
|
38
38
|
|
39
39
|
Proc.wait4(pid, flags=0)
|
40
|
-
Waits for the given child process to exit.
|
40
|
+
Waits for the given child process to exit. Returns a ProcStat structure.
|
41
41
|
Also sets the $? special global variable.
|
42
42
|
|
43
43
|
Proc.waitid(id_type, id_num=nil, options=nil)
|
@@ -46,12 +46,12 @@ Proc.waitid(id_type, id_num=nil, options=nil)
|
|
46
46
|
The state of a child process will change if it terminates, stops because
|
47
47
|
of a signal, becomes trapped or reaches a breakpoint.
|
48
48
|
|
49
|
-
The id_num corresponds to a
|
50
|
-
which may be Process::P_PID, Process::P_PGID or
|
51
|
-
Process::P_ALL, then the id_num is ignored.
|
49
|
+
The id_num corresponds to a process ID or process group ID, depending on
|
50
|
+
the value of +id_type+, which may be Process::P_PID, Process::P_PGID or
|
51
|
+
Process::P_ALL. If +id_type+ is Process::P_ALL, then the +id_num+ is ignored.
|
52
52
|
|
53
53
|
The options argument is used to specify which state changes are to be
|
54
|
-
waited for.
|
54
|
+
waited for. It is constructed from the bitwise-OR of one or more of the
|
55
55
|
following constants:
|
56
56
|
|
57
57
|
Process::WCONTINUED
|
@@ -106,13 +106,13 @@ Process::P_GID
|
|
106
106
|
Any non-system effective process group id.
|
107
107
|
|
108
108
|
Process::P_PROJID
|
109
|
-
A project process id.
|
109
|
+
A project process id. Solaris 8 or later only.
|
110
110
|
|
111
111
|
Process::P_SID
|
112
112
|
A session process id.
|
113
113
|
|
114
114
|
Process::P_TASKID
|
115
|
-
A task process id.
|
115
|
+
A task process id. Solaris 8 or later only.
|
116
116
|
|
117
117
|
Process::P_UID
|
118
118
|
Any non-system effective process user id.
|
@@ -179,14 +179,14 @@ Process::RLIM_SAVED_MAX
|
|
179
179
|
struct.
|
180
180
|
|
181
181
|
== Known Bugs
|
182
|
-
None that I'm aware of.
|
182
|
+
None that I'm aware of. Please log any bugs on the RubyForge project
|
183
183
|
page at http://www.rubyforge.org/projects/shards.
|
184
184
|
|
185
185
|
== License
|
186
186
|
Ruby's
|
187
187
|
|
188
188
|
== Copyright
|
189
|
-
(C) 2003-
|
189
|
+
(C) 2003-2008 Daniel J. Berger
|
190
190
|
All Rights Reserved.
|
191
191
|
|
192
192
|
== Warranty
|
data/ext/extconf.rb
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
########################################################
|
2
|
+
# Use the mkmf.rb file that I provide, so I can use the
|
3
|
+
# have_enum_member method
|
4
|
+
########################################################
|
5
|
+
require 'mkmf'
|
6
|
+
|
7
|
+
# Check to see if Ruby has already defined the various RLIMIT constants
|
8
|
+
# and set an appropriate macro in the source.
|
9
|
+
#
|
10
|
+
begin
|
11
|
+
Process::RLIMIT_AS
|
12
|
+
rescue
|
13
|
+
check_sizeof('int')
|
14
|
+
check_sizeof('long')
|
15
|
+
check_sizeof('long long')
|
16
|
+
unless check_sizeof('rlim_t', 'sys/resource.h')
|
17
|
+
if (2**33).is_a?(Fixnum)
|
18
|
+
$defs.push('-DSIZEOF_RLIM_T 8') # 64 bit
|
19
|
+
else
|
20
|
+
$defs.push('-DSIZEOF_RLIM_T 4') # 32 bit
|
21
|
+
end
|
22
|
+
end
|
23
|
+
else
|
24
|
+
$defs.push('-DRUBY_HAS_RLIMIT') # Used within wait.c
|
25
|
+
end
|
26
|
+
|
27
|
+
have_header('wait.h')
|
28
|
+
|
29
|
+
# wait3 is mandatory.
|
30
|
+
unless have_func('wait3')
|
31
|
+
STDERR.puts 'wait3() function not found'
|
32
|
+
exit
|
33
|
+
end
|
34
|
+
|
35
|
+
# Yay, Linux
|
36
|
+
have_func('str2sig')
|
37
|
+
have_func('strlcpy')
|
38
|
+
|
39
|
+
# wait4, waitid, etc, are optional (HPUX, et al)
|
40
|
+
have_func('wait4')
|
41
|
+
have_func('waitid')
|
42
|
+
have_func('sigsend')
|
43
|
+
have_func('getrusage')
|
44
|
+
have_func('getdtablesize')
|
45
|
+
|
46
|
+
have_struct_member('struct siginfo', 'si_trapno', 'signal.h')
|
47
|
+
have_struct_member('struct siginfo', 'si_pc', 'signal.h')
|
48
|
+
have_struct_member('struct siginfo', 'si_sysarg', 'signal.h')
|
49
|
+
have_struct_member('struct siginfo', 'si_mstate', 'signal.h')
|
50
|
+
have_struct_member('struct siginfo', 'si_faddr', 'signal.h')
|
51
|
+
have_struct_member('struct siginfo', 'si_syscall', 'signal.h')
|
52
|
+
have_struct_member('struct siginfo', 'si_nsysarg', 'signal.h')
|
53
|
+
have_struct_member('struct siginfo', 'si_fault', 'signal.h')
|
54
|
+
have_struct_member('struct siginfo', 'si_tstamp', 'signal.h')
|
55
|
+
|
56
|
+
count = 0
|
57
|
+
|
58
|
+
# Attempt to append the necessary method to the user's mkmf.rb file, after
|
59
|
+
# backing it up first.
|
60
|
+
begin
|
61
|
+
have_const('P_CID', 'signal.h')
|
62
|
+
have_const('P_GID', 'signal.h')
|
63
|
+
have_const('P_MYID', 'signal.h')
|
64
|
+
have_const('P_SID', 'signal.h')
|
65
|
+
have_const('P_UID', 'signal.h')
|
66
|
+
|
67
|
+
# These are only supported by Solaris 8 and later afaik
|
68
|
+
have_const('P_PROJID', 'signal.h')
|
69
|
+
have_const('P_TASKID', 'signal.h')
|
70
|
+
rescue NoMethodError
|
71
|
+
require 'rbconfig'
|
72
|
+
count += 1
|
73
|
+
file = File.join(Config::CONFIG['rubylibdir'], 'mkmf.rb')
|
74
|
+
FileUtils.cp(file, 'mkmf.orig') # Backup original
|
75
|
+
File.open(file, 'a+'){ |fh|
|
76
|
+
fh.puts %Q{
|
77
|
+
# Returns whether or not the constant +const+ can be found in the common
|
78
|
+
# header files, or within a +header+ that you provide. If found, a macro is
|
79
|
+
# passed as a preprocessor constant to the compiler using the constant name,
|
80
|
+
# in uppercase, prepended with 'HAVE_'. This method is also used to test
|
81
|
+
# for the presence of enum values.
|
82
|
+
#
|
83
|
+
# For example, if have_const('FOO') returned true, then the HAVE_CONST_FOO
|
84
|
+
# preprocessor macro would be passed to the compiler.
|
85
|
+
#
|
86
|
+
# This method was added automatically by the proc-wait3 library on
|
87
|
+
# #{Time.now}.
|
88
|
+
#
|
89
|
+
def have_const(const, header = nil, opt = "", &b)
|
90
|
+
checking_for const do
|
91
|
+
header = cpp_include(header)
|
92
|
+
if try_compile(<<"SRC", opt, &b)
|
93
|
+
#\{COMMON_HEADERS\}
|
94
|
+
#\{header\}
|
95
|
+
/* top */
|
96
|
+
static int t = #\{const\};
|
97
|
+
SRC
|
98
|
+
$defs.push(
|
99
|
+
format(
|
100
|
+
"-DHAVE_CONST_%s",
|
101
|
+
const.strip.upcase.tr_s("^A-Z0-9_", "_")
|
102
|
+
)
|
103
|
+
)
|
104
|
+
true
|
105
|
+
else
|
106
|
+
false
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end}
|
110
|
+
}
|
111
|
+
retry unless count >= 2
|
112
|
+
end
|
113
|
+
|
114
|
+
create_makefile('proc/wait3', 'proc')
|
data/{lib → ext}/proc/wait3.c
RENAMED
@@ -771,7 +771,7 @@ static VALUE proc_getrlimit(VALUE mod, VALUE v_resource){
|
|
771
771
|
}
|
772
772
|
|
773
773
|
/*
|
774
|
-
* call-seq
|
774
|
+
* call-seq:
|
775
775
|
* Process.setrlimit(resource, current, max=nil) => nil
|
776
776
|
*
|
777
777
|
* Sets the +current+ (soft) and +max+ (hard) limit for the given +resource+
|
@@ -895,22 +895,27 @@ void Init_wait3()
|
|
895
895
|
rb_define_module_function(rb_mProcess, "waitid", proc_waitid, -1);
|
896
896
|
|
897
897
|
#ifdef WCONTINUED
|
898
|
+
/* The status of any child that was stopped and then continued */
|
898
899
|
rb_define_const(rb_mProcess, "WCONTINUED", INT2FIX(WCONTINUED));
|
899
900
|
#endif
|
900
901
|
|
901
902
|
#ifdef WEXITED
|
903
|
+
/* The status of any child that has terminated */
|
902
904
|
rb_define_const(rb_mProcess, "WEXITED", INT2FIX(WEXITED));
|
903
905
|
#endif
|
904
906
|
|
905
907
|
#ifdef WNOWAIT
|
908
|
+
/* Keeps the process whose status was returned in a waitable state */
|
906
909
|
rb_define_const(rb_mProcess, "WNOWAIT", INT2FIX(WNOWAIT));
|
907
910
|
#endif
|
908
911
|
|
909
912
|
#ifdef WSTOPPED
|
913
|
+
/* The status of any child that has stopped as the result of a signal */
|
910
914
|
rb_define_const(rb_mProcess, "WSTOPPED", INT2FIX(WSTOPPED));
|
911
915
|
#endif
|
912
916
|
|
913
917
|
#ifdef WTRAPPED
|
918
|
+
/* Waits for any child process to become trapped or reach a breakpoint */
|
914
919
|
rb_define_const(rb_mProcess, "WTRAPPED", INT2FIX(WTRAPPED));
|
915
920
|
#endif
|
916
921
|
#endif
|
@@ -918,64 +923,99 @@ void Init_wait3()
|
|
918
923
|
/* Because core Ruby already defines a Process::GID and Process::UID,
|
919
924
|
* I am forced to keep the leading 'P_' for these constants.
|
920
925
|
*/
|
926
|
+
|
927
|
+
/* Any child */
|
921
928
|
rb_define_const(rb_mProcess, "P_ALL", INT2FIX(P_ALL));
|
929
|
+
|
930
|
+
/* Process group ID */
|
922
931
|
rb_define_const(rb_mProcess, "P_PGID", INT2FIX(P_PGID));
|
932
|
+
|
933
|
+
/* Process ID */
|
923
934
|
rb_define_const(rb_mProcess, "P_PID", INT2FIX(P_PID));
|
924
935
|
|
925
936
|
#ifdef HAVE_CONST_P_CID
|
937
|
+
/* Process scheduler class ID */
|
926
938
|
rb_define_const(rb_mProcess, "P_CID", INT2FIX(P_CID));
|
927
939
|
#endif
|
928
940
|
|
929
941
|
#ifdef HAVE_CONST_P_GID
|
942
|
+
/* Non-system process effective group ID */
|
930
943
|
rb_define_const(rb_mProcess, "P_GID", INT2FIX(P_GID));
|
931
944
|
#endif
|
932
945
|
|
933
946
|
#ifdef HAVE_CONST_P_MYID
|
947
|
+
/* Process ID of the calling process */
|
934
948
|
rb_define_const(rb_mProcess, "P_MYID", INT2FIX(P_MYID));
|
935
949
|
#endif
|
936
950
|
|
937
951
|
#ifdef HAVE_CONST_P_SID
|
952
|
+
/* Non-system process session ID */
|
938
953
|
rb_define_const(rb_mProcess, "P_SID", INT2FIX(P_SID));
|
939
954
|
#endif
|
940
955
|
|
941
956
|
#ifdef HAVE_CONST_P_UID
|
957
|
+
/* Non-system process effective user ID */
|
942
958
|
rb_define_const(rb_mProcess, "P_UID", INT2FIX(P_UID));
|
943
959
|
#endif
|
944
960
|
|
945
961
|
#ifdef HAVE_CONST_P_TASKID
|
962
|
+
/* Process task ID */
|
946
963
|
rb_define_const(rb_mProcess, "P_TASKID", INT2FIX(P_TASKID));
|
947
964
|
#endif
|
948
965
|
|
949
966
|
#ifdef HAVE_CONST_P_PROJID
|
967
|
+
/* Process project ID */
|
950
968
|
rb_define_const(rb_mProcess, "P_PROJID", INT2FIX(P_PROJID));
|
951
969
|
#endif
|
952
970
|
|
953
971
|
/* Constants for getrlimit, setrlimit. It appears that these are defined
|
954
|
-
* by Ruby as of 1.8.5.
|
972
|
+
* by Ruby as of 1.8.5. We'll only set the RLIMIT constants for Ruby 1.8.4
|
955
973
|
* or earlier.
|
956
974
|
*/
|
957
975
|
#ifndef RUBY_HAS_RLIMIT
|
976
|
+
/* Maximum size of the process' mapped address space, in bytes */
|
958
977
|
rb_define_const(rb_mProcess, "RLIMIT_AS", INT2FIX(RLIMIT_AS));
|
978
|
+
|
979
|
+
/* Maximum size of a core file in bytes that may be created */
|
959
980
|
rb_define_const(rb_mProcess, "RLIMIT_CORE", INT2FIX(RLIMIT_CORE));
|
981
|
+
|
982
|
+
/* Maximum amount of CPU time, in seconds, the process is allowed to use */
|
960
983
|
rb_define_const(rb_mProcess, "RLIMIT_CPU", INT2FIX(RLIMIT_CPU));
|
984
|
+
|
985
|
+
/* Maximum size of the process' heap, in bytes */
|
961
986
|
rb_define_const(rb_mProcess, "RLIMIT_DATA", INT2FIX(RLIMIT_DATA));
|
987
|
+
|
988
|
+
/* Maximum size of a file, in bytes, that the process may create */
|
962
989
|
rb_define_const(rb_mProcess, "RLIMIT_FSIZE", INT2FIX(RLIMIT_FSIZE));
|
990
|
+
|
991
|
+
/* The maximum value that the kernel may assign to a file descriptor */
|
963
992
|
rb_define_const(rb_mProcess, "RLIMIT_NOFILE", INT2FIX(RLIMIT_NOFILE));
|
993
|
+
|
994
|
+
/* The maximum size of the process' stack, in bytes */
|
964
995
|
rb_define_const(rb_mProcess, "RLIMIT_STACK", INT2FIX(RLIMIT_STACK));
|
996
|
+
|
997
|
+
/* No limit on the resource */
|
965
998
|
rb_define_const(rb_mProcess, "RLIM_INFINITY", RLIM2NUM(RLIM_INFINITY));
|
999
|
+
|
1000
|
+
/* Set the limit to the corresponding saved hard limit */
|
966
1001
|
rb_define_const(rb_mProcess, "RLIM_SAVED_MAX", RLIM2NUM(RLIM_SAVED_MAX));
|
1002
|
+
|
1003
|
+
/* Set the limit to the corresponding saved soft limit */
|
967
1004
|
rb_define_const(rb_mProcess, "RLIM_SAVED_CUR", RLIM2NUM(RLIM_SAVED_CUR));
|
968
1005
|
|
969
1006
|
#ifdef RLIMIT_MEMLOCK
|
1007
|
+
/* The maximum number of bytes that may be locked into RAM */
|
970
1008
|
rb_define_const(rb_mProcess, "RLIMIT_MEMLOCK", INT2FIX(RLIMIT_MEMLOCK));
|
971
1009
|
#endif
|
972
1010
|
|
973
1011
|
#ifdef RLIMIT_VMEM
|
1012
|
+
/* Synonym for RLIMIT_AS */
|
974
1013
|
rb_define_const(rb_mProcess, "RLIMIT_VMEM", INT2FIX(RLIMIT_VMEM));
|
975
1014
|
#endif
|
976
1015
|
#endif
|
977
1016
|
|
978
|
-
|
1017
|
+
/* 1.5.4: The version of this library */
|
1018
|
+
rb_define_const(rb_mProcess, "WAIT3_VERSION", rb_str_new2("1.5.4"));
|
979
1019
|
|
980
1020
|
/* Define this last in our Init_wait3 function */
|
981
1021
|
rb_define_readonly_variable("$?", &v_last_status);
|
data/test/tc_wait3.rb
CHANGED
@@ -1,27 +1,13 @@
|
|
1
1
|
##################################################################
|
2
2
|
# tc_wait3.rb
|
3
3
|
#
|
4
|
-
# Test suite for the Ruby proc-wait3 package.
|
4
|
+
# Test suite for the Ruby proc-wait3 package. You should run this
|
5
|
+
# via the 'test' rake task.
|
5
6
|
##################################################################
|
6
|
-
base = File.basename(Dir.pwd)
|
7
|
-
|
8
|
-
if base == "test" || base =~ /proc-wait3/
|
9
|
-
require "ftools"
|
10
|
-
ext = ".so"
|
11
|
-
ext = ".sl" if RUBY_PLATFORM =~ /hpux/i
|
12
|
-
ext = ".bundle" if RUBY_PLATFORM =~ /darwin|powerpc/i
|
13
|
-
file = "wait3" + ext
|
14
|
-
Dir.chdir("..") if base == "test"
|
15
|
-
Dir.mkdir("proc") rescue nil
|
16
|
-
File.copy(file,"proc")
|
17
|
-
$LOAD_PATH.unshift(Dir.pwd)
|
18
|
-
Dir.chdir("test") rescue nil
|
19
|
-
end
|
20
|
-
|
21
7
|
require "proc/wait3"
|
22
8
|
require "test/unit"
|
23
9
|
|
24
|
-
class TC_Wait3 < Test::Unit::TestCase
|
10
|
+
class TC_Wait3 < Test::Unit::TestCase
|
25
11
|
def setup
|
26
12
|
@proc_stat = nil
|
27
13
|
@proc_stat_members = ["pid", "status", "utime", "stime", "maxrss",
|
@@ -32,7 +18,7 @@ class TC_Wait3 < Test::Unit::TestCase
|
|
32
18
|
end
|
33
19
|
|
34
20
|
def test_wait3_version
|
35
|
-
assert_equal('1.5.
|
21
|
+
assert_equal('1.5.4', Process::WAIT3_VERSION)
|
36
22
|
end
|
37
23
|
|
38
24
|
def test_wait3_basic
|
@@ -76,50 +62,58 @@ unless RUBY_PLATFORM =~ /hpux/i
|
|
76
62
|
end
|
77
63
|
|
78
64
|
def test_waitid_basic
|
79
|
-
|
65
|
+
if RUBY_PLATFORM =~ /mach|darwin|osx/i
|
66
|
+
STDOUT.puts "Skipping 'test_waitid_basic' on this platform"
|
67
|
+
else
|
68
|
+
assert_respond_to(Process, :waitid)
|
69
|
+
end
|
80
70
|
end
|
81
71
|
|
82
72
|
def test_waitid_in_action
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
}
|
73
|
+
if RUBY_PLATFORM =~ /mach|darwin|osx/i
|
74
|
+
STDOUT.puts "Skipping 'test_waitid_in_action' on this platform"
|
75
|
+
else
|
76
|
+
pid = fork{ sleep 1 }
|
88
77
|
|
89
|
-
|
90
|
-
|
91
|
-
|
78
|
+
assert_nothing_raised{
|
79
|
+
Process.waitid(Process::P_PID, pid, Process::WEXITED)
|
80
|
+
}
|
92
81
|
|
93
|
-
|
94
|
-
|
95
|
-
|
82
|
+
assert_raises(TypeError){
|
83
|
+
Process.waitid("foo", pid, Process::WEXITED)
|
84
|
+
}
|
96
85
|
|
97
|
-
|
98
|
-
|
99
|
-
|
86
|
+
assert_raises(TypeError){
|
87
|
+
Process.waitid(Process::P_PID, pid, "foo")
|
88
|
+
}
|
100
89
|
|
101
|
-
|
102
|
-
|
103
|
-
Process.waitid(Process::P_PID, 99999999, Process::WEXITED)
|
90
|
+
assert_raises(TypeError){
|
91
|
+
Process.waitid(Process::P_PID, "foo", Process::WEXITED)
|
104
92
|
}
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
93
|
+
|
94
|
+
if RUBY_PLATFORM.match("linux")
|
95
|
+
assert_raises(Errno::ECHILD){
|
96
|
+
Process.waitid(Process::P_PID, 99999999, Process::WEXITED)
|
97
|
+
}
|
98
|
+
else
|
99
|
+
assert_raises(Errno::EINVAL){
|
100
|
+
Process.waitid(Process::P_PID, 99999999, Process::WEXITED)
|
101
|
+
}
|
102
|
+
end
|
109
103
|
end
|
110
104
|
end
|
111
105
|
|
112
106
|
def test_sigsend_basic
|
113
107
|
if RUBY_PLATFORM.match("linux")
|
114
|
-
puts "test_sigsend_basic
|
108
|
+
puts "Skipping 'test_sigsend_basic' on this platform"
|
115
109
|
else
|
116
110
|
assert_respond_to(Process,:send)
|
117
111
|
end
|
118
112
|
end
|
119
113
|
|
120
114
|
def test_sigsend_in_action
|
121
|
-
if RUBY_PLATFORM
|
122
|
-
puts "test_sigsend_in_action
|
115
|
+
if RUBY_PLATFORM =~ /linux|mach|darwin|osx/i
|
116
|
+
puts "Skipping 'test_sigsend_in_action' on this platform"
|
123
117
|
else
|
124
118
|
pid = fork{ sleep 1 }
|
125
119
|
|
@@ -151,11 +145,15 @@ end
|
|
151
145
|
msg = "Don't panic. It simply appears that this constant is not defined"
|
152
146
|
msg += "on your particular platform. Ignore"
|
153
147
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
148
|
+
unless RUBY_PLATFORM =~ /darwin/i
|
149
|
+
assert_not_nil(Process::WCONTINUED, msg)
|
150
|
+
assert_not_nil(Process::WEXITED, msg)
|
151
|
+
assert_not_nil(Process::WNOWAIT, msg)
|
152
|
+
assert_not_nil(Process::WSTOPPED, msg)
|
153
|
+
unless RUBY_PLATFORM.match("linux")
|
154
|
+
assert_not_nil(Process::WTRAPPED, msg)
|
155
|
+
end
|
156
|
+
end
|
159
157
|
end
|
160
158
|
|
161
159
|
# Skip these tests on Ruby 1.8.5 or later
|
@@ -214,7 +212,7 @@ end
|
|
214
212
|
end
|
215
213
|
|
216
214
|
def test_process_type_flags
|
217
|
-
unless RUBY_PLATFORM
|
215
|
+
unless RUBY_PLATFORM =~ /linux|mach|darwin|osx/i
|
218
216
|
assert_not_nil(Process::P_ALL)
|
219
217
|
assert_not_nil(Process::P_CID)
|
220
218
|
assert_not_nil(Process::P_GID)
|
metadata
CHANGED
@@ -1,51 +1,61 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.0
|
3
|
-
specification_version: 1
|
4
2
|
name: proc-wait3
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.5.
|
7
|
-
date: 2006-10-25 00:00:00 -06:00
|
8
|
-
summary: Adds the wait3, wait4, waitid, pause, sigsend, and getrusage methods to the Process module. It also adds the getrlimit and setrlimit methods for Ruby 1.8.4 or earlier.
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: djberg96@gmail.com
|
12
|
-
homepage: http://www.rubyforge.org/projects/shards
|
13
|
-
rubyforge_project: shards
|
14
|
-
description: Adds the wait3, wait4, waitid, pause, sigsend, and getrusage methods to the Process module. It also adds the getrlimit and setrlimit methods for Ruby 1.8.4 or earlier.
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 1.8.0
|
24
|
-
version:
|
4
|
+
version: 1.5.4
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Daniel J. Berger
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-02-08 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Adds the wait3, wait4, waitid, pause, sigsend, and getrusage methods to the Process module. It also adds the getrlimit and setrlimit methods for Ruby 1.8.4 or earlier.
|
17
|
+
email: djberg96@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions:
|
21
|
+
- ext/extconf.rb
|
22
|
+
extra_rdoc_files:
|
23
|
+
- CHANGES
|
24
|
+
- README
|
25
|
+
- MANIFEST
|
26
|
+
- ext/proc/wait3.c
|
31
27
|
files:
|
32
28
|
- doc/wait3.txt
|
33
29
|
- test/tc_wait3.rb
|
34
|
-
-
|
30
|
+
- ext/proc/wait3.c
|
35
31
|
- CHANGES
|
36
32
|
- README
|
37
|
-
|
38
|
-
|
33
|
+
- MANIFEST
|
34
|
+
has_rdoc: true
|
35
|
+
homepage: http://www.rubyforge.org/projects/shards
|
36
|
+
post_install_message:
|
39
37
|
rdoc_options: []
|
40
38
|
|
41
|
-
|
42
|
-
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
39
|
+
require_paths:
|
40
|
+
- lib
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.8.0
|
46
|
+
version:
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: "0"
|
52
|
+
version:
|
48
53
|
requirements: []
|
49
54
|
|
50
|
-
|
51
|
-
|
55
|
+
rubyforge_project: shards
|
56
|
+
rubygems_version: 1.0.1
|
57
|
+
signing_key:
|
58
|
+
specification_version: 2
|
59
|
+
summary: Adds the wait3, wait4, waitid, pause, sigsend, and getrusage methods to the Process module. It also adds the getrlimit and setrlimit methods for Ruby 1.8.4 or earlier.
|
60
|
+
test_files:
|
61
|
+
- test/tc_wait3.rb
|
data/extconf.rb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
########################################################
|
2
|
-
# Use the mkmf.rb file that I provide, so I can use the
|
3
|
-
# have_enum_member method
|
4
|
-
########################################################
|
5
|
-
require "mkmf"
|
6
|
-
require "ftools"
|
7
|
-
|
8
|
-
File.copy("lib/proc/wait3.c",".")
|
9
|
-
|
10
|
-
# Check to see if Ruby has already defined the various RLIMIT constants
|
11
|
-
# and set an appropriate macro in the source.
|
12
|
-
begin
|
13
|
-
Process::RLIMIT_AS
|
14
|
-
rescue
|
15
|
-
check_sizeof("int")
|
16
|
-
check_sizeof("long")
|
17
|
-
check_sizeof("long long")
|
18
|
-
unless check_sizeof("rlim_t", "sys/resource.h")
|
19
|
-
if (2**33).is_a?(Fixnum)
|
20
|
-
$defs.push("-DSIZEOF_RLIM_T 8") # 64 bit
|
21
|
-
else
|
22
|
-
$defs.push("-DSIZEOF_RLIM_T 4") # 32 bit
|
23
|
-
end
|
24
|
-
end
|
25
|
-
else
|
26
|
-
$defs.push("-DRUBY_HAS_RLIMIT") # Used within wait.c
|
27
|
-
end
|
28
|
-
|
29
|
-
have_header("wait.h")
|
30
|
-
|
31
|
-
# wait3 is mandatory.
|
32
|
-
unless have_func("wait3")
|
33
|
-
STDERR.puts "wait3() function not found"
|
34
|
-
exit
|
35
|
-
end
|
36
|
-
|
37
|
-
# Yay, Linux
|
38
|
-
have_func("str2sig")
|
39
|
-
have_func("strlcpy")
|
40
|
-
|
41
|
-
# wait4, waitid, etc, are optional (HPUX, et al)
|
42
|
-
have_func("wait4")
|
43
|
-
have_func("waitid")
|
44
|
-
have_func("sigsend")
|
45
|
-
have_func("getrusage")
|
46
|
-
have_func("getdtablesize")
|
47
|
-
|
48
|
-
have_struct_member("struct siginfo", "si_trapno", "signal.h")
|
49
|
-
have_struct_member("struct siginfo", "si_pc", "signal.h")
|
50
|
-
have_struct_member("struct siginfo", "si_sysarg", "signal.h")
|
51
|
-
have_struct_member("struct siginfo", "si_mstate", "signal.h")
|
52
|
-
have_struct_member("struct siginfo", "si_faddr", "signal.h")
|
53
|
-
have_struct_member("struct siginfo", "si_syscall", "signal.h")
|
54
|
-
have_struct_member("struct siginfo", "si_nsysarg", "signal.h")
|
55
|
-
have_struct_member("struct siginfo", "si_fault", "signal.h")
|
56
|
-
have_struct_member("struct siginfo", "si_tstamp", "signal.h")
|
57
|
-
|
58
|
-
begin
|
59
|
-
have_const("P_CID", "signal.h")
|
60
|
-
have_const("P_GID", "signal.h")
|
61
|
-
have_const("P_MYID", "signal.h")
|
62
|
-
have_const("P_SID", "signal.h")
|
63
|
-
have_const("P_UID", "signal.h")
|
64
|
-
|
65
|
-
# These are only supported by Solaris 8 and later afaik
|
66
|
-
have_const("P_PROJID", "signal.h")
|
67
|
-
have_const("P_TASKID", "signal.h")
|
68
|
-
rescue NoMethodError
|
69
|
-
STDERR.puts
|
70
|
-
STDERR.puts "STOP!"
|
71
|
-
STDERR.puts
|
72
|
-
STDERR.puts "Please run the patch.rb program and try again"
|
73
|
-
STDERR.puts "See the README file for more details"
|
74
|
-
STDERR.puts "Makefile NOT created"
|
75
|
-
exit
|
76
|
-
end
|
77
|
-
|
78
|
-
create_makefile("proc/wait3")
|