Build breakage with NO_WAITPID macro

e$BIMCO$G$9!#e(B

NO_WAITPID e$B$,e(B define e$B$5$l$k4D6-$Ge(B
process.c e$B$N%3%s%Q%$%k$,DL$j$^$;$s!#e(B

e$B$?$V$s2<5-%Q%C%A$G$J$*$j$^$9!#e(B
e$B$"$H!"e(B wait_each e$B$O;H$o$l$F$J$$$N$Ge(B
e$B>C$7$F$7$^$C$FNI$$$h$&$K;W$$$^$9!#e(B

Index: process.c

— process.c (revision 22454)
+++ process.c (working copy)
@@ -650,7 +650,7 @@

 for (;;) {

result = (rb_pid_t)rb_thread_blocking_region(rb_waitpid_blocking,

  •             st, RUBY_UBF_PROCESS);
    
  •             st, RUBY_UBF_PROCESS, 0);
    
    if (result < 0) {
    if (errno == EINTR) {
    rb_thread_schedule();
    @@ -693,7 +693,7 @@
    waitall_each(rb_pid_t pid, int status, VALUE ary)
    {
    rb_last_status_set(status, pid);
  • rb_ary_push(ary, rb_assoc_new(PIDT2NUM(pid), rb_last_status_get());
  • rb_ary_push(ary, rb_assoc_new(PIDT2NUM(pid),
    rb_last_status_get()));
    return ST_DELETE;
    }
    #endif

e$B$J$+$@$G$9!#e(B

At Fri, 20 Feb 2009 01:12:24 +0900,
shinichiro.h wrote in [ruby-dev:38054]:

NO_WAITPID e$B$,e(B define e$B$5$l$k4D6-$Ge(B
process.c e$B$N%3%s%Q%$%k$,DL$j$^$;$s!#e(B

e$B$?$V$s2<5-%Q%C%A$G$J$*$j$^$9!#e(B

e$B$"$j$,$H$&$4$6$$$^$9!#%3%_%C%H$7$^$7$?!#e(B

e$B$"$H!"e(B wait_each e$B$O;H$o$l$F$J$$$N$Ge(B
e$B>C$7$F$7$^$C$FNI$$$h$&$K;W$$$^$9!#e(B

e$B;H$o$l$F$$$J$$$N$,4V0c$$$N$h$&$J5$$,$7$^$9!#e(BNO_WAITPIDe$B$J4D6-$G$Oe(B
Process.wait(-1)e$B$,Mx$$$F$J$$$H$$$&$3$H$O$"$j$^$;$s$+!#e(B

Index: process.c

— process.c (revision 22587)
+++ process.c (working copy)
@@ -591,4 +591,27 @@ pst_wcoredump(VALUE st)
#define NO_WAITPID
static st_table *pid_tbl;
+
+struct wait_data {

  • rb_pid_t pid;
  • int status;
    +};

+static int
+wait_each(rb_pid_t pid, int status, struct wait_data *data)
+{

  • if (data->status != -1) return ST_STOP;
  • data->pid = pid;
  • data->status = status;
  • return ST_DELETE;
    +}

+static int
+waitall_each(rb_pid_t pid, int status, VALUE ary)
+{

  • rb_last_status_set(status, pid);
  • rb_ary_push(ary, rb_assoc_new(PIDT2NUM(pid),
    rb_last_status_get()));
  • return ST_DELETE;
    +}
    #else
    struct waitpid_arg {
    @@ -636,11 +659,23 @@ retry:
    goto retry;
    }
  • return -1;
  • return (rb_pid_t)-1;
    }
    #else /* NO_WAITPID */
  • if (pid_tbl && st_lookup(pid_tbl, pid, (st_data_t *)st)) {
  • rb_last_status_set(*st, pid);
  • st_delete(pid_tbl, (st_data_t*)&pid, NULL);
  • return pid;
  • if (pid_tbl) {
  • st_data_t status;
  • if (pid == (rb_pid_t)-1) {
  •  struct wait_data data;
    
  •  data.pid = (rb_pid_t)-1;
    
  •  data.status = -1;
    
  •  st_foreach(pid_tbl, wait_each, (st_data_t)&data);
    
  •  if (data.status != -1) {
    
  • rb_last_status_set(data.status, data.pid);
  • return data.pid;
  •  }
    
  • }
  • else if (st_delete(pid_tbl, (st_data_t)pid, &status)) {
  •  rb_last_status_set(*st = (int)status, pid);
    
  •  return pid;
    
  • }
    }

@@ -657,11 +692,11 @@ retry:
continue;
}

  •  return -1;
    
  •  return (rb_pid_t)-1;
    
    }
  • if (result == pid) {
  • if (result == pid || pid == (rb_pid_t)-1) {
    break;
    }
    if (!pid_tbl)
  • pid_tbl = st_init_numtable();
  •  pid_tbl = st_init_numtable();
    
    st_insert(pid_tbl, pid, (st_data_t)st);
    if (!rb_thread_alone()) rb_thread_schedule();
    @@ -674,29 +709,4 @@ retry:
    }

-#ifdef NO_WAITPID
-struct wait_data {

  • rb_pid_t pid;
  • int status;
    -};

-static int
-wait_each(rb_pid_t pid, int status, struct wait_data *data)
-{

  • if (data->status != -1) return ST_STOP;
  • data->pid = pid;
  • data->status = status;
  • return ST_DELETE;
    -}

-static int
-waitall_each(rb_pid_t pid, int status, VALUE ary)
-{

  • rb_last_status_set(status, pid);
  • rb_ary_push(ary, rb_assoc_new(PIDT2NUM(pid),
    rb_last_status_get()));
  • return ST_DELETE;
    -}
    -#endif

/* [MG]:FIXME: I wasn’t sure how this should be done, since ::wait()