[#2529] concerns about Proc,lambda,block — "David A. Black" <dblack@...>

Hi --

39 messages 2004/03/01
[#2531] Re: concerns about Proc,lambda,block — ts <decoux@...> 2004/03/01

>>>>> "D" == David A Black <dblack@wobblini.net> writes:

[#2533] Re: concerns about Proc,lambda,block — "David A. Black" <dblack@...> 2004/03/01

Hi --

[#2537] Re: concerns about Proc,lambda,block — matz@... (Yukihiro Matsumoto) 2004/03/01

Hi,

[#2542] Re: concerns about Proc,lambda,block — Mathieu Bouchard <matju@...> 2004/03/02

[#2545] Re: concerns about Proc,lambda,block — matz@... (Yukihiro Matsumoto) 2004/03/02

Hi,

[#2550] Re: concerns about Proc,lambda,block — Mauricio Fern疣dez <batsman.geo@...> 2004/03/03

On Wed, Mar 03, 2004 at 07:51:10AM +0900, Yukihiro Matsumoto wrote:

[#2703] Proposed patch to add SSL support to net/pop.rb — Daniel Hobe <daniel@...>

This patch adds support to Net::POP for doing POP over SSL. Modeled on how

19 messages 2004/03/27
[#2704] Re: Proposed patch to add SSL support to net/pop.rb — Daniel Hobe <daniel@...> 2004/03/27

This is v2 of the patch. Cleaned up a bit and added some more docs.

[#2707] Re: Proposed patch to add SSL support to net/pop.rb — Daniel Hobe <daniel@...> 2004/03/28

v3 of the patch:

[#2721] Re: Proposed patch to add SSL support to net/pop.rb — Minero Aoki <aamine@...> 2004/03/30

Hi,

process.c changes

From: Daniel Berger <djberge@...>
Date: 2004-03-09 21:18:49 UTC
List: ruby-core #2610
All,

I stumbled across Curt Tilmes' Proc::Wait3 Perl module and it made me
think that Ruby (and probably Perl) should have this built-in.  I
whipped this up quick and it seems to work alright.  I felt a struct was
nicer than returning a huge array (as Chris does), but that can be
changed easily enough.  These two functions could also be reduced to one
function (with a few more "if" statements) if you really wanted.

If this patch is accepted, then I would also suggest deprecating
wait2/waitpid2, since they don't provide any information that
wait3/waitpid3 don't provide (and the latter provide much more).

Regards,

Daniel Berger

= SAMPLE SCRIPTS =

# test_wait3.rb
fork{
   sleep 5
   exit 1
}
#p Process.wait3(Process::WNOHANG)
p Process.wait3

# test_waitpid3.rb
pid = fork{ sleep 3 }
p Time.now
p Process.waitpid3(pid,Process::WNOHANG)
p Time.now
p Process.waitpid3(pid)
p Time.now

= DIFF FILE =

--- process.c	Tue Mar  9 14:00:09 2004
+++ ../ruby-1.8.1/process.c	Wed Dec 10 00:57:06 2003
@@ -456,105 +456,6 @@
     return rb_assoc_new(pid, rb_last_status);
 }
 
-static VALUE proc_wait3(int argc, VALUE *argv){
-   int status;
-   int flags = 0;
-   struct rusage r;
-   pid_t pid;
-   VALUE rbFlags = Qnil;
-   VALUE rbStruct =
rb_struct_define("ProcStruct","pid","status","utime","stime",
-      "maxrss","minflt","majflt","nswap","inblock","oublock","msgsnd",
-      "msgrcv","nsignals","nvcsw","nivcsw",0
-   );
-
-   rb_scan_args(argc,argv,"01",&rbFlags);
-
-   if(Qnil != rbFlags){
-      flags = NUM2INT(rbFlags);
-   }
-
-   pid =  wait3(&status, flags, &r);
-   if(pid < 0){
-      rb_sys_fail(0);
-   }
-   else if(pid > 0){
-      return rb_struct_new(rbStruct,
-         INT2NUM(pid),
-         INT2NUM(status),
-         INT2NUM(r.ru_utime.tv_sec + (r.ru_utime.tv_usec/1000.0)),
-         INT2NUM(r.ru_stime.tv_sec + (r.ru_stime.tv_usec/1000.0)),
-         INT2NUM(r.ru_maxrss),
-         INT2NUM(r.ru_ixrss),
-         INT2NUM(r.ru_idrss),
-         INT2NUM(r.ru_isrss),
-         INT2NUM(r.ru_minflt),
-         INT2NUM(r.ru_majflt),
-         INT2NUM(r.ru_nswap),
-         INT2NUM(r.ru_inblock),
-         INT2NUM(r.ru_oublock),
-         INT2NUM(r.ru_msgsnd),
-         INT2NUM(r.ru_msgrcv),
-         INT2NUM(r.ru_nsignals),
-         INT2NUM(r.ru_nvcsw),
-         INT2NUM(r.ru_nivcsw)
-      );
-   }
-   else{
-      return rb_last_status = Qnil;
-   }
-}
-
-/* wait4 is actually waitpid3 - who comes up with this? */
-static VALUE proc_waitpid3(int argc, VALUE *argv){
-   int status;
-   int flags = 0;
-   struct rusage r;
-   pid_t pid;
-   VALUE rbPid;
-   VALUE rbFlags = Qnil;
-   VALUE rbStruct =
rb_struct_define("ProcStruct","pid","status","utime","stime",
-      "maxrss","minflt","majflt","nswap","inblock","oublock","msgsnd",
-      "msgrcv","nsignals","nvcsw","nivcsw",0
-   );
-
-   rb_scan_args(argc,argv,"11",&rbPid,&rbFlags);
-   pid = NUM2INT(rbPid);
-
-   if(Qnil != rbFlags){
-      flags = NUM2INT(rbFlags);
-   }
-
-   pid =  wait4(pid, &status, flags, &r);
-   if(pid < 0){
-      rb_sys_fail(0);
-   }
-   else if(pid > 0){
-      return rb_struct_new(rbStruct,
-         INT2NUM(pid),
-         INT2NUM(status),
-         INT2NUM(r.ru_utime.tv_sec + (r.ru_utime.tv_usec/1000.0)),
-         INT2NUM(r.ru_stime.tv_sec + (r.ru_stime.tv_usec/1000.0)),
-         INT2NUM(r.ru_maxrss),
-         INT2NUM(r.ru_ixrss),
-         INT2NUM(r.ru_idrss),
-         INT2NUM(r.ru_isrss),
-         INT2NUM(r.ru_minflt),
-         INT2NUM(r.ru_majflt),
-         INT2NUM(r.ru_nswap),
-         INT2NUM(r.ru_inblock),
-         INT2NUM(r.ru_oublock),
-         INT2NUM(r.ru_msgsnd),
-         INT2NUM(r.ru_msgrcv),
-         INT2NUM(r.ru_nsignals),
-         INT2NUM(r.ru_nvcsw),
-         INT2NUM(r.ru_nivcsw)
-      );
-   }
-   else{
-      return rb_last_status = Qnil;
-   }
-}
-
 static VALUE
 proc_waitall()
 {
@@ -2436,10 +2337,8 @@
     rb_define_module_function(rb_mProcess, "kill", rb_f_kill, -1);
     rb_define_module_function(rb_mProcess, "wait", proc_wait, -1);
     rb_define_module_function(rb_mProcess, "wait2", proc_wait2, -1);
-    rb_define_module_function(rb_mProcess, "wait3", proc_wait3, -1);
     rb_define_module_function(rb_mProcess, "waitpid", proc_wait, -1);
     rb_define_module_function(rb_mProcess, "waitpid2", proc_wait2, -1);
-    rb_define_module_function(rb_mProcess, "waitpid3", proc_waitpid3,
-1);
     rb_define_module_function(rb_mProcess, "waitall", proc_waitall, 0);
     rb_define_module_function(rb_mProcess, "detach", proc_detach, 1);

In This Thread

Prev Next