# Build breakage with NO\_WAITPID macro

**URL:** <https://www.ruby-forum.com/t/build-breakage-with-no-waitpid-macro/160781>\
**Category:** Development\
**Created:** [February 19, 2009, 5:13pm UTC](https://www.ruby-forum.com/t/build-breakage-with-no-waitpid-macro/160781 "2009-02-19T17:13:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shinichiro.h](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/34f0e0/32.png) [@shinichiro.h](https://www.ruby-forum.com/u/shinichiro.h)\
**Post date:** [February 19, 2009, 5:13pm UTC](https://www.ruby-forum.com/t/build-breakage-with-no-waitpid-macro/160781/1 "2009-02-19T17:13:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![shinichiro.h](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/34f0e0/32.png) [@shinichiro.h](https://www.ruby-forum.com/u/shinichiro.h)\
**Post date:** [February 24, 2009, 3:08am UTC](https://www.ruby-forum.com/t/build-breakage-with-no-waitpid-macro/160781/2 "2009-02-24T03:08:14Z")

</div>

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()
