From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: Date: Thu, 5 Dec 2013 23:59:26 +0100 From: cinap_lenrek@felloff.net To: 9fans@9fans.net In-Reply-To: <27644fbad2e3cd6556717fb4f3ba7d1c@brasstown.quanstro.net> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] rio leak Topicbox-Message-UUID: 930a0bc6-ead8-11e9-9d60-3106f5b1d025 i just tried something out. it appears that _schedexecwait()'s purpose is to serve thredwaitchan(): Threadwaitchan returns a channel of pointers to Waitmsg structures (see wait(2)). When an exec'ed process exits, a pointer to a Waitmsg is sent to this channel. These Waitmsg structures have been allocated with malloc(2) and should be freed after use. when threadwaitchan isnt used, we can rfork the execing child with RFNOWAIT which will make the process doing the original procexecl() not wait for the child. i just tried this out with rio (and abaco) and it seems to work fine. diff -r 42807d2e3f4b sys/src/libthread/main.c --- a/sys/src/libthread/main.c Thu Dec 05 22:43:44 2013 +0100 +++ b/sys/src/libthread/main.c Fri Dec 06 23:50:34 2013 +0100 @@ -121,9 +121,10 @@ int _schedexec(Execargs *e) { - int pid; + int pid, flag; - switch(pid = rfork(RFREND|RFNOTEG|RFFDG|RFMEM|RFPROC)){ + flag = (_threadwaitchan == nil) ? RFNOWAIT : 0; + switch(pid = rfork(RFREND|RFNOTEG|RFFDG|RFMEM|RFPROC|flag)){ case 0: efork(e); default: this is saving a couple of few processes. is it worth it? -- cinap