9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: cinap_lenrek@felloff.net
To: 9fans@9fans.net
Subject: Re: [9fans] rio leak
Date: Thu,  5 Dec 2013 23:59:26 +0100	[thread overview]
Message-ID: <af4b600c70d2c88d71c96e6b980e9e74@felloff.net> (raw)
In-Reply-To: <27644fbad2e3cd6556717fb4f3ba7d1c@brasstown.quanstro.net>

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



  reply	other threads:[~2013-12-05 22:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-05  3:22 erik quanstrom
2013-12-05 22:59 ` cinap_lenrek [this message]
2013-12-06  1:51   ` erik quanstrom

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=af4b600c70d2c88d71c96e6b980e9e74@felloff.net \
    --to=cinap_lenrek@felloff.net \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).