by the way, the following program runs without asserting for me with or without the waits.
- erik --- #include <u.h> #include <libc.h> void task(void **p) { assert(*p == nil); *p = (void*)(uintptr)getpid(); } void spawn(void (*t)(void**), void **p) { int pid; switch(pid = rfork(RFMEM|RFPROC)){ case -1: sysfatal("spawn: rfork: %r"); case 0: t(p); exits(""); default: USED(pid); return; } } void main(void) { int i, k; void **p; Waitmsg *w; p = privalloc(); k = 0; for(i = 0; i < 1024; i++){ spawn(task, p); for(k++; k > 16; k--){ if((w = wait()) == nil) break; free(w); } } exits(""); }