From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Sat, 5 Sep 2015 09:41:02 -0700 To: 9fans@9fans.net Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] Privalloc(2) and rfork(RFPROC|RFMEM) (was: a pair nec bugs) Topicbox-Message-UUID: 68fa57fe-ead9-11e9-9d60-3106f5b1d025 by the way, the following program runs without asserting for me with or without the waits. - erik --- #include #include 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(""); }