proc-wait3 1.5.6 → 1.6.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.
data/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
+ == 1.6.0 - 28-Aug-2011
2
+ * Removed the getrlimit and setrlimit methods. Ruby has supported these methods
3
+ since Ruby 1.8.5, so I think it's time to finally dump them.
4
+ * Fixed two build warnings regarding unused variables and one 32/64 cast warning.
5
+
1
6
  == 1.5.6 - 7-Jan-2010
2
7
  * Checks are now made for the si_fd, si_utime, si_status and si_stime siginfo_t
3
8
  struct members. This addresses build failures on OS X 10.5 and later where
data/README CHANGED
@@ -4,10 +4,21 @@
4
4
  and setrlimit methods.
5
5
 
6
6
  = Installation
7
-
8
7
  gem install proc-wait3
9
8
 
10
- == Tested Platforms
9
+ = Synopsis
10
+ require 'proc/wait3'
11
+
12
+ pid = fork{
13
+ sleep 1
14
+ exit 2
15
+ }
16
+
17
+ puts Time.now.to_s
18
+ Process.wait3
19
+ puts $?.exitstatus # => 2
20
+
21
+ = Tested Platforms
11
22
  * Solaris
12
23
  * Linux
13
24
  * FreeBSD
data/Rakefile CHANGED
@@ -1,15 +1,19 @@
1
1
  require 'rake'
2
+ require 'rake/clean'
2
3
  require 'rake/testtask'
3
4
  require 'fileutils'
5
+ require 'rbconfig'
6
+ include Config
4
7
 
5
- desc "Clean the generated build files"
6
- task :clean do |t|
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
12
- end
8
+ CLEAN.include(
9
+ '**/*.gem', # Gem files
10
+ '**/*.rbc', # Rubinius
11
+ '**/*.o', # C object file
12
+ '**/*.log', # Ruby extension build log
13
+ '**/Makefile', # C Makefile
14
+ '**/conftest.dSYM', # OS X build directory
15
+ "**/*.#{CONFIG['DLEXT']}" # C shared object
16
+ )
13
17
 
14
18
  desc "Build the source (but don't install it)"
15
19
  task :build => [:clean] do |t|
@@ -20,15 +24,18 @@ task :build => [:clean] do |t|
20
24
  end
21
25
  end
22
26
 
23
- desc "Install the proc-wait3 library"
24
- task :install => [:build] do |t|
25
- sh 'make install'
26
- end
27
+ namespace :gem do
28
+ desc "Create the proc-wait3 gem"
29
+ task :create => [:clean] do
30
+ spec = eval(IO.read('proc-wait3.gemspec'))
31
+ Gem::Builder.new(spec).build
32
+ end
27
33
 
28
- desc "Build the gem"
29
- task :gem do
30
- spec = eval(IO.read('proc-wait3.gemspec'))
31
- Gem::Builder.new(spec).build
34
+ desc "Install the proc-wait3 gem"
35
+ task :install => [:create] do |t|
36
+ file = Dir['*.gem'].first
37
+ sh "gem install #{file}"
38
+ end
32
39
  end
33
40
 
34
41
  namespace :example do
@@ -64,3 +71,5 @@ Rake::TestTask.new do |t|
64
71
  t.warning = true
65
72
  t.verbose = true
66
73
  end
74
+
75
+ task :default => :test
data/ext/extconf.rb CHANGED
@@ -4,47 +4,29 @@
4
4
  ########################################################
5
5
  require 'mkmf'
6
6
 
7
+ dir_config('proc-wait3')
8
+
7
9
  # We need this for older versions of Ruby.
8
10
  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)
11
+ checking_for const do
12
+ header = cpp_include(header)
13
+ if try_compile(<<"SRC", opt, &b)
12
14
  #{COMMON_HEADERS}
13
15
  #{header}
14
16
  /* top */
15
17
  static int t = #{const};
16
18
  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
-
30
- # Check to see if Ruby has already defined the various RLIMIT constants
31
- # and set an appropriate macro in the source.
32
- #
33
- begin
34
- Process::RLIMIT_AS
35
- rescue
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
19
+ $defs.push(
20
+ format(
21
+ "-DHAVE_CONST_%s",
22
+ const.strip.upcase.tr_s("^A-Z0-9_", "_")
23
+ )
24
+ )
25
+ true
42
26
  else
43
- $defs.push('-DSIZEOF_RLIM_T 4') # 32 bit
27
+ false
44
28
  end
45
29
  end
46
- else
47
- $defs.push('-DRUBY_HAS_RLIMIT') # Used within wait.c
48
30
  end
49
31
 
50
32
  have_header('wait.h')
data/ext/proc/wait3.c CHANGED
@@ -320,7 +320,6 @@ static VALUE proc_waitid(int argc, VALUE* argv, VALUE mod){
320
320
  idtype_t idtype;
321
321
  id_t id = 0;
322
322
  int options = 0;
323
- int i = 0;
324
323
 
325
324
  rb_scan_args(argc, argv, "12", &v_type, &v_id, &v_options);
326
325
 
@@ -395,7 +394,10 @@ static VALUE proc_waitid(int argc, VALUE* argv, VALUE mod){
395
394
  );
396
395
  }
397
396
  else{
398
- VALUE v_utime = Qnil, v_status = Qnil, v_stime = Qnil, v_fd = Qnil;
397
+ VALUE v_utime = Qnil, v_status = Qnil, v_stime = Qnil;
398
+ #ifdef HAVE_ST_SI_FD
399
+ VALUE v_fd = Qnil;
400
+ #endif
399
401
  #ifdef HAVE_ST_SI_TRAPNO
400
402
  VALUE v_trapno = Qnil;
401
403
  #endif
@@ -427,6 +429,10 @@ static VALUE proc_waitid(int argc, VALUE* argv, VALUE mod){
427
429
  int sig = infop.si_signo;
428
430
  int code = infop.si_code;
429
431
 
432
+ #if defined(HAVE_ST_SI_SYSARG) || defined(HAVE_ST_SI_MSTATE)
433
+ int i = 0;
434
+ #endif
435
+
430
436
  /* If Process.waitid returns because a child process was found that
431
437
  * satisfies the conditions indicated by +id_type+ and +options+, then
432
438
  * the si_signo struct member will always be SIGCHLD.
@@ -570,12 +576,14 @@ static VALUE proc_waitid(int argc, VALUE* argv, VALUE mod){
570
576
  */
571
577
  static VALUE proc_pause(int argc, VALUE* argv, VALUE mod){
572
578
  VALUE v_signals;
573
- int i, len;
579
+ int i;
580
+ long len;
574
581
 
575
582
  rb_scan_args(argc, argv, "0*", &v_signals);
576
583
 
577
- /* Iterate over each signal, calling sigset for each one */
584
+ // Iterate over each signal, calling sigset for each one
578
585
  len = RARRAY_LEN(v_signals);
586
+
579
587
  if(len > 0){
580
588
  VALUE v_val;
581
589
  char signame[SIG2STR_MAX];
@@ -760,66 +768,6 @@ static VALUE proc_getrusage(int argc, VALUE* argv, VALUE mod){
760
768
  }
761
769
  #endif
762
770
 
763
- #ifndef RUBY_HAS_RLIMIT
764
- /*
765
- * call-seq:
766
- * Process.getrlimit(resource) => [cur_limit, max_limit]
767
- *
768
- * Returns a two element array consisting of the hard and soft limit
769
- * for the current process for the given +resource+. The array consists of
770
- * either numeric values or the word "infinite".
771
- */
772
- static VALUE proc_getrlimit(VALUE mod, VALUE v_resource){
773
- struct rlimit limits;
774
- VALUE v_array = rb_ary_new();
775
-
776
- rb_secure(2);
777
-
778
- if(getrlimit(NUM2INT(v_resource), &limits) < 0)
779
- rb_sys_fail("getrlimit");
780
-
781
- if(limits.rlim_cur == RLIM_INFINITY)
782
- rb_ary_push(v_array, rb_str_new2("infinity"));
783
- else
784
- rb_ary_push(v_array, INT2FIX(limits.rlim_cur));
785
-
786
- if(limits.rlim_max == RLIM_INFINITY)
787
- rb_ary_push(v_array, rb_str_new2("infinity"));
788
- else
789
- rb_ary_push(v_array, INT2FIX(limits.rlim_max));
790
-
791
- return v_array;
792
- }
793
-
794
- /*
795
- * call-seq:
796
- * Process.setrlimit(resource, current, max=nil) => nil
797
- *
798
- * Sets the +current+ (soft) and +max+ (hard) limit for the given +resource+
799
- * for the current process. If +max+ is nil it is set to the same value as
800
- * +current+.
801
- */
802
- static VALUE proc_setrlimit(int argc, VALUE* argv, VALUE mod){
803
- VALUE v_res, v_cur, v_max;
804
- struct rlimit limits;
805
-
806
- rb_secure(2);
807
-
808
- rb_scan_args(argc, argv, "21", &v_res, &v_cur, &v_max);
809
-
810
- if(NIL_P(v_max))
811
- v_max = v_cur;
812
-
813
- limits.rlim_cur = RLIM2NUM(v_cur);
814
- limits.rlim_max = RLIM2NUM(v_max);
815
-
816
- if(setrlimit(NUM2UINT(v_res), &limits) < 0)
817
- rb_sys_fail("setrlimit");
818
-
819
- return Qnil;
820
- }
821
- #endif
822
-
823
771
  #ifdef HAVE_GETDTABLESIZE
824
772
  /*
825
773
  * call-seq:
@@ -851,11 +799,6 @@ void Init_wait3()
851
799
  rb_define_module_function(rb_mProcess, "wait3", proc_wait3, -1);
852
800
  rb_define_module_function(rb_mProcess, "pause", proc_pause, -1);
853
801
 
854
- #ifndef RUBY_HAS_RLIMIT
855
- rb_define_module_function(rb_mProcess, "getrlimit", proc_getrlimit, 1);
856
- rb_define_module_function(rb_mProcess, "setrlimit", proc_setrlimit, -1);
857
- #endif
858
-
859
802
  #ifdef HAVE_GETDTABLESIZE
860
803
  rb_define_module_function(rb_mProcess,"getdtablesize",proc_getdtablesize,0);
861
804
  #endif
@@ -1006,54 +949,8 @@ void Init_wait3()
1006
949
  rb_define_const(rb_mProcess, "P_PROJID", INT2FIX(P_PROJID));
1007
950
  #endif
1008
951
 
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
- */
1013
- #ifndef RUBY_HAS_RLIMIT
1014
- /* Maximum size of the process' mapped address space, in bytes */
1015
- rb_define_const(rb_mProcess, "RLIMIT_AS", INT2FIX(RLIMIT_AS));
1016
-
1017
- /* Maximum size of a core file in bytes that may be created */
1018
- rb_define_const(rb_mProcess, "RLIMIT_CORE", INT2FIX(RLIMIT_CORE));
1019
-
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));
1022
-
1023
- /* Maximum size of the process' heap, in bytes */
1024
- rb_define_const(rb_mProcess, "RLIMIT_DATA", INT2FIX(RLIMIT_DATA));
1025
-
1026
- /* Maximum size of a file, in bytes, that the process may create */
1027
- rb_define_const(rb_mProcess, "RLIMIT_FSIZE", INT2FIX(RLIMIT_FSIZE));
1028
-
1029
- /* The maximum value that the kernel may assign to a file descriptor */
1030
- rb_define_const(rb_mProcess, "RLIMIT_NOFILE", INT2FIX(RLIMIT_NOFILE));
1031
-
1032
- /* The maximum size of the process' stack, in bytes */
1033
- rb_define_const(rb_mProcess, "RLIMIT_STACK", INT2FIX(RLIMIT_STACK));
1034
-
1035
- /* No limit on the resource */
1036
- rb_define_const(rb_mProcess, "RLIM_INFINITY", RLIM2NUM(RLIM_INFINITY));
1037
-
1038
- /* Set the limit to the corresponding saved hard limit */
1039
- rb_define_const(rb_mProcess, "RLIM_SAVED_MAX", RLIM2NUM(RLIM_SAVED_MAX));
1040
-
1041
- /* Set the limit to the corresponding saved soft limit */
1042
- rb_define_const(rb_mProcess, "RLIM_SAVED_CUR", RLIM2NUM(RLIM_SAVED_CUR));
1043
-
1044
- #ifdef 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));
1047
- #endif
1048
-
1049
- #ifdef RLIMIT_VMEM
1050
- /* Synonym for RLIMIT_AS */
1051
- rb_define_const(rb_mProcess, "RLIMIT_VMEM", INT2FIX(RLIMIT_VMEM));
1052
- #endif
1053
- #endif
1054
-
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"));
952
+ /* 1.6.0: The version of the proc-wait3 library */
953
+ rb_define_const(rb_mProcess, "WAIT3_VERSION", rb_str_new2("1.6.0"));
1057
954
 
1058
955
  /* Define this last in our Init_wait3 function */
1059
956
  rb_define_readonly_variable("$?", &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.5.6'
5
+ spec.version = '1.6.0'
6
6
  spec.author = 'Daniel J. Berger'
7
7
  spec.license = 'Artistic 2.0'
8
8
  spec.email = 'djberg96@gmail.com'
@@ -10,20 +10,16 @@ Gem::Specification.new do |spec|
10
10
  spec.platform = Gem::Platform::RUBY
11
11
  spec.summary = 'Adds wait3, wait4 and other methods to the Process module'
12
12
  spec.test_file = 'test/test_proc_wait3.rb'
13
- spec.has_rdoc = true
14
13
  spec.extensions = ['ext/extconf.rb']
15
14
  spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
16
15
 
17
- spec.required_ruby_version = '>= 1.8.2'
18
-
19
16
  spec.rubyforge_project = 'shards'
20
17
  spec.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST', 'ext/proc/wait3.c']
21
18
 
22
- spec.add_development_dependency('test-unit', '>= 2.0.3')
19
+ spec.add_development_dependency('test-unit', '>= 2.1.0')
23
20
 
24
21
  spec.description = <<-EOF
25
22
  The proc-wait3 library adds the wait3, wait4, waitid, pause, sigsend,
26
- and getrusage methods to the Process module. It also adds the getrlimit
27
- and setrlimit methods for Ruby 1.8.4 or earlier.
23
+ and getrusage methods to the Process module.
28
24
  EOF
29
25
  end
@@ -37,7 +37,7 @@ class TC_Proc_Wait3 < Test::Unit::TestCase
37
37
  end
38
38
 
39
39
  def test_wait3_version
40
- assert_equal('1.5.6', Process::WAIT3_VERSION)
40
+ assert_equal('1.6.0', Process::WAIT3_VERSION)
41
41
  end
42
42
 
43
43
  def test_wait3_basic
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proc-wait3
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.6
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 6
8
+ - 0
9
+ version: 1.6.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Daniel J. Berger
@@ -9,20 +14,25 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-01-07 00:00:00 -07:00
17
+ date: 2011-08-28 00:00:00 -06:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: test-unit
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
20
25
  requirements:
21
26
  - - ">="
22
27
  - !ruby/object:Gem::Version
23
- version: 2.0.3
24
- version:
25
- description: " The proc-wait3 library adds the wait3, wait4, waitid, pause, sigsend,\n and getrusage methods to the Process module. It also adds the getrlimit\n and setrlimit methods for Ruby 1.8.4 or earlier.\n"
28
+ segments:
29
+ - 2
30
+ - 1
31
+ - 0
32
+ version: 2.1.0
33
+ type: :development
34
+ version_requirements: *id001
35
+ description: " The proc-wait3 library adds the wait3, wait4, waitid, pause, sigsend,\n and getrusage methods to the Process module.\n"
26
36
  email: djberg96@gmail.com
27
37
  executables: []
28
38
 
@@ -58,21 +68,25 @@ rdoc_options: []
58
68
  require_paths:
59
69
  - lib
60
70
  required_ruby_version: !ruby/object:Gem::Requirement
71
+ none: false
61
72
  requirements:
62
73
  - - ">="
63
74
  - !ruby/object:Gem::Version
64
- version: 1.8.2
65
- version:
75
+ segments:
76
+ - 0
77
+ version: "0"
66
78
  required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
67
80
  requirements:
68
81
  - - ">="
69
82
  - !ruby/object:Gem::Version
83
+ segments:
84
+ - 0
70
85
  version: "0"
71
- version:
72
86
  requirements: []
73
87
 
74
88
  rubyforge_project: shards
75
- rubygems_version: 1.3.5
89
+ rubygems_version: 1.3.7
76
90
  signing_key:
77
91
  specification_version: 3
78
92
  summary: Adds wait3, wait4 and other methods to the Process module