proc-wait3 1.5.5 → 1.5.6

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 CHANGED
@@ -1,3 +1,13 @@
1
+ == 1.5.6 - 7-Jan-2010
2
+ * Checks are now made for the si_fd, si_utime, si_status and si_stime siginfo_t
3
+ struct members. This addresses build failures on OS X 10.5 and later where
4
+ those struct members went mysteriously MIA.
5
+ * The have_const method is no longer added to your mkmf.rb file. It is simply
6
+ defined in the extconf.rb file.
7
+ * Some gemspec and Rakefile refactoring.
8
+ * Updates to the README.
9
+ * Source code moved to github.
10
+
1
11
  == 1.5.5 - 8-Aug-2009
2
12
  * Now compatible with Ruby 1.9.x.
3
13
  * License changed to Artistic 2.0.
data/README CHANGED
@@ -1,54 +1,36 @@
1
- == Description
2
- Adds the wait3, wait4, waitid, pause, sigsend, and getrusage methods to
3
- the Process module. For Ruby 1.8.4 or earlier, it also adds the getrlimit
4
- and setrlimit methods.
1
+ = Description
2
+ Adds the wait3, wait4, waitid, pause, sigsend, and getrusage methods to
3
+ the Process module. For Ruby 1.8.4 or earlier, it also adds the getrlimit
4
+ and setrlimit methods.
5
5
 
6
- == Installation
7
- === Remote Gem Installation
8
- gem install proc-wait3
9
- === Local Installation
10
- rake install
6
+ = Installation
7
+
8
+ gem install proc-wait3
11
9
 
12
10
  == Tested Platforms
13
- * Solaris
14
- * Linux
15
- * FreeBSD
16
- * OS X
17
-
18
- == Warnings
19
- Linux users who compile with gcc -Wall will notice a few warnings. These
20
- are harmless (and unavoidable atm).
21
-
22
- == Applying the mkmf.diff patch
23
- In order to install this package, you will need to patch your mkmf.rb file with
24
- the provided diff file. This is necessary because I need a way to determine
25
- if certain idtype_t enum (const) values are defined. The patch adds a
26
- "have_const" method (and does nothing else). See ruby-core:4422 and related
27
- threads for more information. Also available as ruby-Patches-1486 on the
28
- RubyForge project page for Ruby.
29
-
30
- To apply the patch, simply run "ruby patch.rb". Note that you may need to be
31
- root to apply the patch. This may fail in Ruby 1.8.5 or later. Since there's
32
- no good way to make a compatible diff, you will just have to edit the mkmf.rb
33
- file manually.
34
-
35
- == Integration with Ruby's process.c
36
- I considered simply providing a patch to the core process.c file, but I
37
- decided against it for two reasons. First, I wanted to get something
38
- out more quickly rather than waiting for approval from the core developers who,
39
- based on an earlier post, seem somewhat gun-shy about integrating support
40
- for wait3() and wait4() based, I think, on portability concerns.
41
-
42
- Second, and more importantly, I don't like the cProcStatus class. The
43
- extra inspection code seems like an awful lot of work for very little gain.
44
- The overloaded methods are also overkill, and do nothing but save me the
45
- trouble of typing the word "status", since all they're for is comparing or
46
- operating on the status attribute.
47
-
48
- That being said, I would be willing to write a patch for process.c if there's
49
- enough support for it. If you'd like to see that, please log a comment and/or
50
- feature request on the project page at
51
- http://www.rubyforge.org/projects/shards.
52
-
53
- == Additional Documentation
54
- Please see the doc/wait3.txt file for detailed documentation.
11
+ * Solaris
12
+ * Linux
13
+ * FreeBSD
14
+ * OS X
15
+
16
+ = Warnings
17
+ Linux users who compile with gcc -Wall will notice a few warnings. These
18
+ are harmless (and unavoidable atm).
19
+
20
+ = Integration with Ruby's process.c
21
+
22
+ I considered simply providing a patch to the core process.c file, but I
23
+ decided against it for two reasons. First, I wanted to get something
24
+ out more quickly rather than waiting for approval from the core developers
25
+ who, based on an earlier post, seem somewhat gun-shy about integrating support
26
+ for wait3() and wait4() based, I think, on portability concerns.
27
+
28
+ Second, and more importantly, I don't like the cProcStatus class. The
29
+ extra inspection code seems like an awful lot of work for very little gain.
30
+ The overloaded methods are also overkill, and do nothing but save me the
31
+ trouble of typing the word "status", since all they're for is comparing or
32
+ operating on the status attribute.
33
+
34
+ = Additional Documentation
35
+
36
+ Please see the doc/wait3.txt file for detailed documentation.
data/Rakefile CHANGED
@@ -4,102 +4,63 @@ require 'fileutils'
4
4
 
5
5
  desc "Clean the generated build files"
6
6
  task :clean do |t|
7
- Dir.chdir('ext') do
8
- sh 'make distclean' if File.exists?('wait3.o')
9
- rm 'proc/wait3.' + Config::CONFIG['DLEXT'] rescue nil
10
- end
7
+ Dir.chdir('ext') do
8
+ sh 'make distclean' rescue nil
9
+ rm 'proc/wait3.' + Config::CONFIG['DLEXT'] rescue nil
10
+ rm_rf 'conftest.dSYM' if File.exists?('conftest.dSYM') # OS X
11
+ end
11
12
  end
12
13
 
13
14
  desc "Build the source (but don't install it)"
14
- task :build => [:patch, :clean] do |t|
15
- Dir.chdir('ext') do
16
- ruby 'extconf.rb'
17
- sh 'make'
18
- FileUtils.mv 'wait3.' + Config::CONFIG['DLEXT'], 'proc'
19
- end
15
+ task :build => [:clean] do |t|
16
+ Dir.chdir('ext') do
17
+ ruby 'extconf.rb'
18
+ sh 'make'
19
+ FileUtils.mv 'wait3.' + Config::CONFIG['DLEXT'], 'proc'
20
+ end
20
21
  end
21
22
 
22
23
  desc "Install the proc-wait3 library"
23
24
  task :install => [:build] do |t|
24
- sh 'make install'
25
+ sh 'make install'
25
26
  end
26
27
 
27
- desc 'Run the Process.getrusage example program'
28
- task :example_getrusage => [:build] do
29
- ruby '-Iext examples/example_getrusage.rb'
28
+ desc "Build the gem"
29
+ task :gem do
30
+ spec = eval(IO.read('proc-wait3.gemspec'))
31
+ Gem::Builder.new(spec).build
30
32
  end
31
33
 
32
- desc 'Run the Process.pause example program'
33
- task :example_pause => [:build] do
34
- ruby '-Iext examples/example_pause.rb'
35
- end
34
+ namespace :example do
35
+ desc 'Run the Process.getrusage example program'
36
+ task :getrusage => [:build] do
37
+ ruby '-Iext examples/example_getrusage.rb'
38
+ end
36
39
 
37
- desc 'Run the Process.wait3 example program'
38
- task :example_wait3 => [:build] do
39
- ruby '-Iext examples/example_wait3.rb'
40
- end
40
+ desc 'Run the Process.pause example program'
41
+ task :pause => [:build] do
42
+ ruby '-Iext examples/example_pause.rb'
43
+ end
41
44
 
42
- desc 'Run the Process.wait4 example program'
43
- task :example_wait4 => [:build] do
44
- ruby '-Iext examples/example_wait4.rb'
45
- end
45
+ desc 'Run the Process.wait3 example program'
46
+ task :wait3 => [:build] do
47
+ ruby '-Iext examples/example_wait3.rb'
48
+ end
46
49
 
47
- desc 'Run the Process.waitid example program'
48
- task :example_waitid => [:build] do
49
- ruby '-Iext examples/example_waitid.rb'
50
- end
50
+ desc 'Run the Process.wait4 example program'
51
+ task :wait4 => [:build] do
52
+ ruby '-Iext examples/example_wait4.rb'
53
+ end
51
54
 
52
- Rake::TestTask.new do |t|
53
- task :test => [:build]
54
- t.libs << 'ext'
55
- t.warning = true
56
- t.verbose = true
55
+ desc 'Run the Process.waitid example program'
56
+ task :waitid => [:build] do
57
+ ruby '-Iext examples/example_waitid.rb'
58
+ end
57
59
  end
58
60
 
59
- desc "Patch your mkmf.rb file so that it supports have_const. Must be root."
60
- task :patch do |t|
61
- require 'mkmf'
62
- unless defined? have_const
63
- file = File.join(Config::CONFIG['rubylibdir'], 'mkmf.rb')
64
- date = Time.now
65
-
66
- FileUtils.cp(file, 'mkmf.orig') # Backup original
67
-
68
- File.open(file, 'a+'){ |fh|
69
- fh.puts %Q{
70
- # Returns whether or not the constant +const+ can be found in the common
71
- # header files, or within a +header+ that you provide. If found, a macro is
72
- # passed as a preprocessor constant to the compiler using the constant name,
73
- # in uppercase, prepended with 'HAVE_'. This method is also used to test
74
- # for the presence of enum values.
75
- #
76
- # For example, if have_const('FOO') returned true, then the HAVE_CONST_FOO
77
- # preprocessor macro would be passed to the compiler.
78
- #
79
- # This method was added automatically by the proc-wait3 library on
80
- # #{date}.
81
- #
82
- def have_const(const, header = nil, opt = "", &b)
83
- checking_for const do
84
- header = cpp_include(header)
85
- if try_compile(<<"SRC", opt, &b)
86
- #\{COMMON_HEADERS\}
87
- #\{header\}
88
- /* top */
89
- static int t = #\{const\};
90
- SRC
91
- $defs.push(
92
- format(
93
- "-DHAVE_CONST_%s",
94
- const.strip.upcase.tr_s("^A-Z0-9_", "_")
95
- )
96
- )
97
- true
98
- else
99
- false
100
- end
101
- end
102
- end}
103
- }
104
- end
61
+ Rake::TestTask.new do |t|
62
+ task :test => [:build]
63
+ t.libs << 'ext'
64
+ t.warning = true
65
+ t.verbose = true
105
66
  end
data/ext/extconf.rb CHANGED
@@ -4,32 +4,55 @@
4
4
  ########################################################
5
5
  require 'mkmf'
6
6
 
7
+ # We need this for older versions of Ruby.
8
+ def have_const(const, header = nil, opt = "", &b)
9
+ checking_for const do
10
+ header = cpp_include(header)
11
+ if try_compile(<<"SRC", opt, &b)
12
+ #{COMMON_HEADERS}
13
+ #{header}
14
+ /* top */
15
+ static int t = #{const};
16
+ SRC
17
+ $defs.push(
18
+ format(
19
+ "-DHAVE_CONST_%s",
20
+ const.strip.upcase.tr_s("^A-Z0-9_", "_")
21
+ )
22
+ )
23
+ true
24
+ else
25
+ false
26
+ end
27
+ end
28
+ end
29
+
7
30
  # Check to see if Ruby has already defined the various RLIMIT constants
8
31
  # and set an appropriate macro in the source.
9
32
  #
10
33
  begin
11
- Process::RLIMIT_AS
34
+ Process::RLIMIT_AS
12
35
  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
36
+ check_sizeof('int')
37
+ check_sizeof('long')
38
+ check_sizeof('long long')
39
+ unless check_sizeof('rlim_t', 'sys/resource.h')
40
+ if (2**33).is_a?(Fixnum)
41
+ $defs.push('-DSIZEOF_RLIM_T 8') # 64 bit
42
+ else
43
+ $defs.push('-DSIZEOF_RLIM_T 4') # 32 bit
44
+ end
45
+ end
23
46
  else
24
- $defs.push('-DRUBY_HAS_RLIMIT') # Used within wait.c
47
+ $defs.push('-DRUBY_HAS_RLIMIT') # Used within wait.c
25
48
  end
26
49
 
27
50
  have_header('wait.h')
28
51
 
29
52
  # wait3 is mandatory.
30
53
  unless have_func('wait3')
31
- STDERR.puts 'wait3() function not found'
32
- exit
54
+ STDERR.puts 'wait3() function not found'
55
+ exit
33
56
  end
34
57
 
35
58
  # Yay, Linux
@@ -43,6 +66,7 @@ have_func('sigsend')
43
66
  have_func('getrusage')
44
67
  have_func('getdtablesize')
45
68
 
69
+ have_struct_member('struct siginfo', 'si_fd', 'signal.h')
46
70
  have_struct_member('struct siginfo', 'si_trapno', 'signal.h')
47
71
  have_struct_member('struct siginfo', 'si_pc', 'signal.h')
48
72
  have_struct_member('struct siginfo', 'si_sysarg', 'signal.h')
@@ -52,67 +76,22 @@ have_struct_member('struct siginfo', 'si_syscall', 'signal.h')
52
76
  have_struct_member('struct siginfo', 'si_nsysarg', 'signal.h')
53
77
  have_struct_member('struct siginfo', 'si_fault', 'signal.h')
54
78
  have_struct_member('struct siginfo', 'si_tstamp', 'signal.h')
79
+ have_struct_member('struct siginfo', 'si_utime', 'signal.h')
80
+ have_struct_member('struct siginfo', 'si_status', 'signal.h')
81
+ have_struct_member('struct siginfo', 'si_stime', 'signal.h')
55
82
 
56
- count = 0
83
+ have_const('P_CID', 'signal.h')
84
+ have_const('P_GID', 'signal.h')
85
+ have_const('P_MYID', 'signal.h')
86
+ have_const('P_SID', 'signal.h')
87
+ have_const('P_UID', 'signal.h')
57
88
 
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
- have_const('P_ALL', 'signal.h') || have_const('P_ALL', 'sys/wait.h')
68
- have_const('P_PGID', 'signal.h') || have_const('P_PGID', 'sys/wait.h')
69
- have_const('P_PID', 'signal.h') || have_const('P_PID', 'sys/wait.h')
89
+ have_const('P_ALL', 'signal.h') || have_const('P_ALL', 'sys/wait.h')
90
+ have_const('P_PGID', 'signal.h') || have_const('P_PGID', 'sys/wait.h')
91
+ have_const('P_PID', 'signal.h') || have_const('P_PID', 'sys/wait.h')
70
92
 
71
- # These are only supported by Solaris 8 and later afaik
72
- have_const('P_PROJID', 'signal.h')
73
- have_const('P_TASKID', 'signal.h')
74
- rescue NoMethodError
75
- require 'rbconfig'
76
- count += 1
77
- file = File.join(Config::CONFIG['rubylibdir'], 'mkmf.rb')
78
- FileUtils.cp(file, 'mkmf.orig') # Backup original
79
- File.open(file, 'a+'){ |fh|
80
- fh.puts %Q{
81
- # Returns whether or not the constant +const+ can be found in the common
82
- # header files, or within a +header+ that you provide. If found, a macro is
83
- # passed as a preprocessor constant to the compiler using the constant name,
84
- # in uppercase, prepended with 'HAVE_'. This method is also used to test
85
- # for the presence of enum values.
86
- #
87
- # For example, if have_const('FOO') returned true, then the HAVE_CONST_FOO
88
- # preprocessor macro would be passed to the compiler.
89
- #
90
- # This method was added automatically by the proc-wait3 library on
91
- # #{Time.now}.
92
- #
93
- def have_const(const, header = nil, opt = "", &b)
94
- checking_for const do
95
- header = cpp_include(header)
96
- if try_compile(<<"SRC", opt, &b)
97
- #\{COMMON_HEADERS\}
98
- #\{header\}
99
- /* top */
100
- static int t = #\{const\};
101
- SRC
102
- $defs.push(
103
- format(
104
- "-DHAVE_CONST_%s",
105
- const.strip.upcase.tr_s("^A-Z0-9_", "_")
106
- )
107
- )
108
- true
109
- else
110
- false
111
- end
112
- end
113
- end}
114
- }
115
- retry unless count >= 2
116
- end
93
+ # These are only supported by Solaris 8 and later afaik
94
+ have_const('P_PROJID', 'signal.h')
95
+ have_const('P_TASKID', 'signal.h')
117
96
 
118
97
  create_makefile('proc/wait3', 'proc')
data/ext/proc/wait3.c CHANGED
@@ -145,7 +145,7 @@ static VALUE pst_wstopsig(int status)
145
145
 
146
146
  /*
147
147
  * call-seq:
148
- * Proc.wait3(flags=nil)
148
+ * Process.wait3(flags=nil)
149
149
  *
150
150
  * Delays its caller until a signal is received or one of its child processes
151
151
  * terminates or stops due to tracing.
@@ -210,7 +210,7 @@ static VALUE proc_wait3(int argc, VALUE *argv, VALUE mod){
210
210
  #ifdef HAVE_WAIT4
211
211
  /*
212
212
  * call-seq:
213
- * Proc.wait4(pid, flags=0)
213
+ * Process.wait4(pid, flags=0)
214
214
  *
215
215
  * Waits for the given child process to exit. Returns a ProcStat structure.
216
216
  * Also sets the $? special global variable.
@@ -279,7 +279,7 @@ static VALUE proc_wait4(int argc, VALUE *argv, VALUE mod){
279
279
  #ifdef HAVE_WAITID
280
280
  /*
281
281
  * call-seq:
282
- * Proc.waitid(id_type, id_num=nil, options=nil)
282
+ * Process.waitid(id_type, id_num=nil, options=nil)
283
283
  *
284
284
  * Suspends the calling process until one of its children changes state,
285
285
  * returning immediately if a child process changed state prior to the call.
@@ -432,9 +432,15 @@ static VALUE proc_waitid(int argc, VALUE* argv, VALUE mod){
432
432
  * the si_signo struct member will always be SIGCHLD.
433
433
  */
434
434
  if(sig == SIGCHLD){
435
+ #ifdef HAVE_ST_SI_UTIME
435
436
  v_utime = ULL2NUM(infop.si_utime);
437
+ #endif
438
+ #ifdef HAVE_ST_SI_STATUS
436
439
  v_status = ULL2NUM(infop.si_status);
440
+ #endif
441
+ #ifdef HAVE_ST_SI_STIME
437
442
  v_stime = ULL2NUM(infop.si_stime);
443
+ #endif
438
444
  }
439
445
 
440
446
  if(sig == SIGBUS || sig == SIGFPE || sig == SIGILL || sig == SIGSEGV ||
@@ -449,7 +455,9 @@ static VALUE proc_waitid(int argc, VALUE* argv, VALUE mod){
449
455
  }
450
456
 
451
457
  if(sig == SIGXFSZ){
458
+ #ifdef HAVE_ST_SI_FD
452
459
  v_fd = INT2FIX(infop.si_fd);
460
+ #endif
453
461
  if(code == POLL_IN || code == POLL_OUT || code == POLL_MSG){
454
462
  v_band = LONG2FIX(infop.si_band);
455
463
  }
@@ -494,11 +502,11 @@ static VALUE proc_waitid(int argc, VALUE* argv, VALUE mod){
494
502
  #endif
495
503
 
496
504
  v_last_status = rb_struct_new(v_siginfo_struct,
497
- INT2FIX(infop.si_signo), /* Probably SIGCHLD */
498
- INT2FIX(infop.si_errno), /* 0 means no error */
499
- INT2FIX(infop.si_code), /* Should be anything but SI_NOINFO */
500
- INT2FIX(infop.si_pid), /* Real PID that sent the signal */
501
- INT2FIX(infop.si_uid), /* Real UID of process that sent signal */
505
+ INT2FIX(infop.si_signo), // Probably SIGCHLD
506
+ INT2FIX(infop.si_errno), // 0 means no error
507
+ INT2FIX(infop.si_code), // Should be anything but SI_NOINFO
508
+ INT2FIX(infop.si_pid), // Real PID that sent the signal
509
+ INT2FIX(infop.si_uid), // Real UID of process that sent signal
502
510
  v_utime,
503
511
  v_status,
504
512
  v_stime,
@@ -508,7 +516,9 @@ static VALUE proc_waitid(int argc, VALUE* argv, VALUE mod){
508
516
  #ifdef HAVE_ST_SI_PC
509
517
  v_pc,
510
518
  #endif
519
+ #ifdef HAVE_ST_SI_FD
511
520
  v_fd,
521
+ #endif
512
522
  v_band,
513
523
  #ifdef HAVE_ST_SI_FADDR
514
524
  v_addr,
@@ -830,210 +840,221 @@ static VALUE proc_getdtablesize(VALUE mod){
830
840
  */
831
841
  void Init_wait3()
832
842
  {
833
- v_procstat_struct =
834
- rb_struct_define("ProcStat","pid","status","utime","stime","maxrss",
835
- "ixrss", "idrss", "isrss", "minflt","majflt","nswap","inblock",
836
- "oublock","msgsnd", "msgrcv","nsignals","nvcsw","nivcsw","stopped",
837
- "signaled","exited","success","coredump","exitstatus","termsig",
838
- "stopsig",NULL
839
- );
843
+ v_procstat_struct =
844
+ rb_struct_define("ProcStat","pid","status","utime","stime","maxrss",
845
+ "ixrss", "idrss", "isrss", "minflt","majflt","nswap","inblock",
846
+ "oublock","msgsnd", "msgrcv","nsignals","nvcsw","nivcsw","stopped",
847
+ "signaled","exited","success","coredump","exitstatus","termsig",
848
+ "stopsig",NULL
849
+ );
840
850
 
841
- rb_define_module_function(rb_mProcess, "wait3", proc_wait3, -1);
842
- rb_define_module_function(rb_mProcess, "pause", proc_pause, -1);
851
+ rb_define_module_function(rb_mProcess, "wait3", proc_wait3, -1);
852
+ rb_define_module_function(rb_mProcess, "pause", proc_pause, -1);
843
853
 
844
854
  #ifndef RUBY_HAS_RLIMIT
845
- rb_define_module_function(rb_mProcess, "getrlimit", proc_getrlimit, 1);
846
- rb_define_module_function(rb_mProcess, "setrlimit", proc_setrlimit, -1);
855
+ rb_define_module_function(rb_mProcess, "getrlimit", proc_getrlimit, 1);
856
+ rb_define_module_function(rb_mProcess, "setrlimit", proc_setrlimit, -1);
847
857
  #endif
848
858
 
849
859
  #ifdef HAVE_GETDTABLESIZE
850
- rb_define_module_function(rb_mProcess,"getdtablesize",proc_getdtablesize,0);
860
+ rb_define_module_function(rb_mProcess,"getdtablesize",proc_getdtablesize,0);
851
861
  #endif
852
862
 
853
863
  #ifdef HAVE_SIGSEND
854
- rb_define_module_function(rb_mProcess, "sigsend", proc_sigsend, -1);
864
+ rb_define_module_function(rb_mProcess, "sigsend", proc_sigsend, -1);
855
865
  #endif
856
866
 
857
867
  #ifdef HAVE_WAIT4
858
- rb_define_module_function(rb_mProcess, "wait4", proc_wait4, -1);
868
+ rb_define_module_function(rb_mProcess, "wait4", proc_wait4, -1);
859
869
  #endif
860
870
 
861
871
  #ifdef HAVE_GETRUSAGE
862
- v_usage_struct =
863
- rb_struct_define("RUsage","utime","stime","maxrss","ixrss","idrss",
864
- "isrss","minflt","majflt","nswap","inblock","oublock","msgsnd",
865
- "msgrcv","nsignals","nvcsw","nivcsw",NULL
866
- );
872
+ v_usage_struct =
873
+ rb_struct_define("RUsage","utime","stime","maxrss","ixrss","idrss",
874
+ "isrss","minflt","majflt","nswap","inblock","oublock","msgsnd",
875
+ "msgrcv","nsignals","nvcsw","nivcsw",NULL
876
+ );
867
877
 
868
- rb_define_module_function(rb_mProcess, "getrusage", proc_getrusage, -1);
878
+ rb_define_module_function(rb_mProcess, "getrusage", proc_getrusage, -1);
869
879
  #endif
870
880
 
871
881
  #ifdef HAVE_WAITID
872
- v_siginfo_struct =
873
- rb_struct_define("SigInfo","signo","errno","code","pid","uid",
874
- "utime","status","stime"
882
+ v_siginfo_struct =
883
+ rb_struct_define("SigInfo", "signo", "errno", "code", "pid", "uid"
884
+ #ifdef HAVE_ST_SI_UTIME
885
+ ,"utime"
886
+ #endif
887
+ #ifdef HAVE_ST_SI_STATUS
888
+ ,"status"
889
+ #endif
890
+ #ifdef HAVE_ST_SI_STIME
891
+ ,"stime"
892
+ #endif
875
893
  #ifdef HAVE_ST_SI_TRAPNO
876
- ,"trapno"
894
+ ,"trapno"
877
895
  #endif
878
896
  #ifdef HAVE_ST_SI_PC
879
- ,"pc"
897
+ ,"pc"
898
+ #endif
899
+ #ifdef HAVE_ST_SI_FD
900
+ ,"fd"
880
901
  #endif
881
- ,"fd","band"
902
+ ,"band"
882
903
  #ifdef HAVE_ST_SI_FADDR
883
- ,"faddr"
904
+ ,"faddr"
884
905
  #endif
885
906
  #ifdef HAVE_ST_SI_TSTAMP
886
- ,"tstamp"
907
+ ,"tstamp"
887
908
  #endif
888
909
  #ifdef HAVE_ST_SI_SYSCALL
889
- ,"syscall"
910
+ ,"syscall"
890
911
  #endif
891
912
  #ifdef HAVE_ST_SI_NSYSARG
892
- ,"nsysarg"
913
+ ,"nsysarg"
893
914
  #endif
894
915
  #ifdef HAVE_ST_SI_FAULT
895
- ,"fault"
916
+ ,"fault"
896
917
  #endif
897
918
  #ifdef HAVE_ST_SI_SYSARG
898
- ,"sysarg"
919
+ ,"sysarg"
899
920
  #endif
900
921
  #ifdef HAVE_ST_SI_MSTATE
901
- ,"mstate"
922
+ ,"mstate"
902
923
  #endif
903
- ,"entity", NULL
904
- );
924
+ ,"entity", NULL
925
+ );
905
926
 
906
- rb_define_module_function(rb_mProcess, "waitid", proc_waitid, -1);
927
+ rb_define_module_function(rb_mProcess, "waitid", proc_waitid, -1);
907
928
 
908
929
  #ifdef WCONTINUED
909
- /* The status of any child that was stopped and then continued */
910
- rb_define_const(rb_mProcess, "WCONTINUED", INT2FIX(WCONTINUED));
930
+ /* The status of any child that was stopped and then continued */
931
+ rb_define_const(rb_mProcess, "WCONTINUED", INT2FIX(WCONTINUED));
911
932
  #endif
912
933
 
913
934
  #ifdef WEXITED
914
- /* The status of any child that has terminated */
915
- rb_define_const(rb_mProcess, "WEXITED", INT2FIX(WEXITED));
935
+ /* The status of any child that has terminated */
936
+ rb_define_const(rb_mProcess, "WEXITED", INT2FIX(WEXITED));
916
937
  #endif
917
938
 
918
939
  #ifdef WNOWAIT
919
- /* Keeps the process whose status was returned in a waitable state */
920
- rb_define_const(rb_mProcess, "WNOWAIT", INT2FIX(WNOWAIT));
940
+ /* Keeps the process whose status was returned in a waitable state */
941
+ rb_define_const(rb_mProcess, "WNOWAIT", INT2FIX(WNOWAIT));
921
942
  #endif
922
943
 
923
944
  #ifdef WSTOPPED
924
- /* The status of any child that has stopped as the result of a signal */
925
- rb_define_const(rb_mProcess, "WSTOPPED", INT2FIX(WSTOPPED));
945
+ /* The status of any child that has stopped as the result of a signal */
946
+ rb_define_const(rb_mProcess, "WSTOPPED", INT2FIX(WSTOPPED));
926
947
  #endif
927
948
 
928
949
  #ifdef WTRAPPED
929
- /* Waits for any child process to become trapped or reach a breakpoint */
930
- rb_define_const(rb_mProcess, "WTRAPPED", INT2FIX(WTRAPPED));
950
+ /* Waits for any child process to become trapped or reach a breakpoint */
951
+ rb_define_const(rb_mProcess, "WTRAPPED", INT2FIX(WTRAPPED));
931
952
  #endif
932
953
  #endif
933
954
 
934
- /* Because core Ruby already defines a Process::GID and Process::UID,
935
- * I am forced to keep the leading 'P_' for these constants.
936
- */
955
+ /* Because core Ruby already defines a Process::GID and Process::UID,
956
+ * I am forced to keep the leading 'P_' for these constants.
957
+ */
937
958
 
938
959
  #ifdef HAVE_CONST_P_ALL
939
- /* Any child */
940
- rb_define_const(rb_mProcess, "P_ALL", INT2FIX(P_ALL));
960
+ /* Any child */
961
+ rb_define_const(rb_mProcess, "P_ALL", INT2FIX(P_ALL));
941
962
  #endif
942
963
 
943
964
  #ifdef HAVE_CONST_P_PGID
944
- /* Process group ID */
945
- rb_define_const(rb_mProcess, "P_PGID", INT2FIX(P_PGID));
965
+ /* Process group ID */
966
+ rb_define_const(rb_mProcess, "P_PGID", INT2FIX(P_PGID));
946
967
  #endif
947
968
 
948
969
  #ifdef HAVE_CONST_P_PID
949
- /* Process ID */
950
- rb_define_const(rb_mProcess, "P_PID", INT2FIX(P_PID));
970
+ /* Process ID */
971
+ rb_define_const(rb_mProcess, "P_PID", INT2FIX(P_PID));
951
972
  #endif
952
973
 
953
974
  #ifdef HAVE_CONST_P_CID
954
- /* Process scheduler class ID */
955
- rb_define_const(rb_mProcess, "P_CID", INT2FIX(P_CID));
975
+ /* Process scheduler class ID */
976
+ rb_define_const(rb_mProcess, "P_CID", INT2FIX(P_CID));
956
977
  #endif
957
978
 
958
979
  #ifdef HAVE_CONST_P_GID
959
- /* Non-system process effective group ID */
960
- rb_define_const(rb_mProcess, "P_GID", INT2FIX(P_GID));
980
+ /* Non-system process effective group ID */
981
+ rb_define_const(rb_mProcess, "P_GID", INT2FIX(P_GID));
961
982
  #endif
962
983
 
963
984
  #ifdef HAVE_CONST_P_MYID
964
- /* Process ID of the calling process */
965
- rb_define_const(rb_mProcess, "P_MYID", INT2FIX(P_MYID));
985
+ /* Process ID of the calling process */
986
+ rb_define_const(rb_mProcess, "P_MYID", INT2FIX(P_MYID));
966
987
  #endif
967
988
 
968
989
  #ifdef HAVE_CONST_P_SID
969
- /* Non-system process session ID */
970
- rb_define_const(rb_mProcess, "P_SID", INT2FIX(P_SID));
990
+ /* Non-system process session ID */
991
+ rb_define_const(rb_mProcess, "P_SID", INT2FIX(P_SID));
971
992
  #endif
972
993
 
973
994
  #ifdef HAVE_CONST_P_UID
974
- /* Non-system process effective user ID */
975
- rb_define_const(rb_mProcess, "P_UID", INT2FIX(P_UID));
995
+ /* Non-system process effective user ID */
996
+ rb_define_const(rb_mProcess, "P_UID", INT2FIX(P_UID));
976
997
  #endif
977
998
 
978
999
  #ifdef HAVE_CONST_P_TASKID
979
- /* Process task ID */
980
- rb_define_const(rb_mProcess, "P_TASKID", INT2FIX(P_TASKID));
1000
+ /* Process task ID */
1001
+ rb_define_const(rb_mProcess, "P_TASKID", INT2FIX(P_TASKID));
981
1002
  #endif
982
1003
 
983
1004
  #ifdef HAVE_CONST_P_PROJID
984
- /* Process project ID */
985
- rb_define_const(rb_mProcess, "P_PROJID", INT2FIX(P_PROJID));
1005
+ /* Process project ID */
1006
+ rb_define_const(rb_mProcess, "P_PROJID", INT2FIX(P_PROJID));
986
1007
  #endif
987
1008
 
988
- /* Constants for getrlimit, setrlimit. It appears that these are defined
989
- * by Ruby as of 1.8.5. We'll only set the RLIMIT constants for Ruby 1.8.4
990
- * or earlier.
991
- */
1009
+ /* Constants for getrlimit, setrlimit. It appears that these are defined
1010
+ * by Ruby as of 1.8.5. We'll only set the RLIMIT constants for Ruby 1.8.4
1011
+ * or earlier.
1012
+ */
992
1013
  #ifndef RUBY_HAS_RLIMIT
993
- /* Maximum size of the process' mapped address space, in bytes */
994
- rb_define_const(rb_mProcess, "RLIMIT_AS", INT2FIX(RLIMIT_AS));
1014
+ /* Maximum size of the process' mapped address space, in bytes */
1015
+ rb_define_const(rb_mProcess, "RLIMIT_AS", INT2FIX(RLIMIT_AS));
995
1016
 
996
- /* Maximum size of a core file in bytes that may be created */
997
- rb_define_const(rb_mProcess, "RLIMIT_CORE", INT2FIX(RLIMIT_CORE));
1017
+ /* Maximum size of a core file in bytes that may be created */
1018
+ rb_define_const(rb_mProcess, "RLIMIT_CORE", INT2FIX(RLIMIT_CORE));
998
1019
 
999
- /* Maximum amount of CPU time, in seconds, the process is allowed to use */
1000
- rb_define_const(rb_mProcess, "RLIMIT_CPU", INT2FIX(RLIMIT_CPU));
1020
+ /* Maximum amount of CPU time, in seconds, the process is allowed to use */
1021
+ rb_define_const(rb_mProcess, "RLIMIT_CPU", INT2FIX(RLIMIT_CPU));
1001
1022
 
1002
- /* Maximum size of the process' heap, in bytes */
1003
- rb_define_const(rb_mProcess, "RLIMIT_DATA", INT2FIX(RLIMIT_DATA));
1023
+ /* Maximum size of the process' heap, in bytes */
1024
+ rb_define_const(rb_mProcess, "RLIMIT_DATA", INT2FIX(RLIMIT_DATA));
1004
1025
 
1005
- /* Maximum size of a file, in bytes, that the process may create */
1006
- rb_define_const(rb_mProcess, "RLIMIT_FSIZE", INT2FIX(RLIMIT_FSIZE));
1026
+ /* Maximum size of a file, in bytes, that the process may create */
1027
+ rb_define_const(rb_mProcess, "RLIMIT_FSIZE", INT2FIX(RLIMIT_FSIZE));
1007
1028
 
1008
- /* The maximum value that the kernel may assign to a file descriptor */
1009
- rb_define_const(rb_mProcess, "RLIMIT_NOFILE", INT2FIX(RLIMIT_NOFILE));
1029
+ /* The maximum value that the kernel may assign to a file descriptor */
1030
+ rb_define_const(rb_mProcess, "RLIMIT_NOFILE", INT2FIX(RLIMIT_NOFILE));
1010
1031
 
1011
- /* The maximum size of the process' stack, in bytes */
1012
- rb_define_const(rb_mProcess, "RLIMIT_STACK", INT2FIX(RLIMIT_STACK));
1032
+ /* The maximum size of the process' stack, in bytes */
1033
+ rb_define_const(rb_mProcess, "RLIMIT_STACK", INT2FIX(RLIMIT_STACK));
1013
1034
 
1014
- /* No limit on the resource */
1015
- rb_define_const(rb_mProcess, "RLIM_INFINITY", RLIM2NUM(RLIM_INFINITY));
1035
+ /* No limit on the resource */
1036
+ rb_define_const(rb_mProcess, "RLIM_INFINITY", RLIM2NUM(RLIM_INFINITY));
1016
1037
 
1017
- /* Set the limit to the corresponding saved hard limit */
1018
- rb_define_const(rb_mProcess, "RLIM_SAVED_MAX", RLIM2NUM(RLIM_SAVED_MAX));
1038
+ /* Set the limit to the corresponding saved hard limit */
1039
+ rb_define_const(rb_mProcess, "RLIM_SAVED_MAX", RLIM2NUM(RLIM_SAVED_MAX));
1019
1040
 
1020
- /* Set the limit to the corresponding saved soft limit */
1021
- rb_define_const(rb_mProcess, "RLIM_SAVED_CUR", RLIM2NUM(RLIM_SAVED_CUR));
1041
+ /* Set the limit to the corresponding saved soft limit */
1042
+ rb_define_const(rb_mProcess, "RLIM_SAVED_CUR", RLIM2NUM(RLIM_SAVED_CUR));
1022
1043
 
1023
1044
  #ifdef RLIMIT_MEMLOCK
1024
- /* The maximum number of bytes that may be locked into RAM */
1025
- rb_define_const(rb_mProcess, "RLIMIT_MEMLOCK", INT2FIX(RLIMIT_MEMLOCK));
1045
+ /* The maximum number of bytes that may be locked into RAM */
1046
+ rb_define_const(rb_mProcess, "RLIMIT_MEMLOCK", INT2FIX(RLIMIT_MEMLOCK));
1026
1047
  #endif
1027
1048
 
1028
1049
  #ifdef RLIMIT_VMEM
1029
- /* Synonym for RLIMIT_AS */
1030
- rb_define_const(rb_mProcess, "RLIMIT_VMEM", INT2FIX(RLIMIT_VMEM));
1050
+ /* Synonym for RLIMIT_AS */
1051
+ rb_define_const(rb_mProcess, "RLIMIT_VMEM", INT2FIX(RLIMIT_VMEM));
1031
1052
  #endif
1032
1053
  #endif
1033
1054
 
1034
- /* 1.5.5: The version of the proc-wait3 library */
1035
- rb_define_const(rb_mProcess, "WAIT3_VERSION", rb_str_new2("1.5.5"));
1055
+ /* 1.5.6: The version of the proc-wait3 library */
1056
+ rb_define_const(rb_mProcess, "WAIT3_VERSION", rb_str_new2("1.5.6"));
1036
1057
 
1037
- /* Define this last in our Init_wait3 function */
1038
- rb_define_readonly_variable("$?", &v_last_status);
1058
+ /* Define this last in our Init_wait3 function */
1059
+ rb_define_readonly_variable("$?", &v_last_status);
1039
1060
  }