9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@9fans.net
Subject: Re: [9fans] APE and listen(2B)
Date: Thu, 27 Nov 2008 09:54:39 -0500	[thread overview]
Message-ID: <b66ccdb4c92100075eeb3caa2560248a@quanstro.net> (raw)
In-Reply-To: <140e7ec30811262349m764d4166kdd44141bf6afc2a3@mail.gmail.com>

> On Thu, Nov 27, 2008 at 1:35 PM,  <lucio@proxima.alt.za> wrote:
>> Now, (a) I'm hoping someone can compile reveal.c (pcc -o reveal
>> -D_POSIX_SOURCES -D_BSD_EXTENSION reveal.c -lbsd) in a pristine APE
>> environment and prove to me that it works unmodified or, (b) somebody
>> can give me some pointers on figuring out how to make sure it works.
>
> # pcc -o reveal -D_POSIX_SOURCE -D_BSD_EXTENSION reveal.c -lbsd
> cpp: reveal.c:58 No newline at end of file
> /tmp/reveal.c:45[stdin:934] syntax error, last name: socklen_t
> /tmp/reveal.c:55[stdin:944] case/default outside a switch
> /tmp/reveal.c:58[stdin:947] syntax error, last name: 0
> pcc: cpp: 8c 71799: error
>
>  After removing the (socklen_t*) typecast...
> # pcc -o reveal -D_POSIX_SOURCE -D_BSD_EXTENSION reveal.c -lbsd
> # ./reveal
> ERRNO: 12
> socket accept: Invalid argument
>
> -sqweek

the problem seems to be in ape/lib/bsd/listen.c.  after the
fork, he sets up atexit(_killmuxsid).  the problem is that
this is _killmuxsid

void
_killmuxsid(void)
{
	if(_muxsid != -1 && (_mainpid == getpid() || _mainpid == -1))
		kill(-_muxsid,SIGTERM);
}

unless i've missed something, there are no arrangements
made to properly reference count the mux fd between processes.

children detach (_detachbuf) so they won't kill off the mux process, but
in the parent, _mainpid is still set, so as soon as the parent
exits, the mux should die.

the real solution involves reference counting.  but in your case,
not forking would make more sense.  in fact, if you wanted
to start reveal from listen(1), you could dispense with the
for(;;) and the fork.

- erik




  parent reply	other threads:[~2008-11-27 14:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-27  4:35 lucio
2008-11-27  7:49 ` sqweek
2008-11-27  9:40   ` lucio
2008-11-27 14:54   ` erik quanstrom [this message]
2008-11-27 15:16     ` lucio
2008-11-28 17:24 ` Skip Tavakkolian
2008-12-04 17:18 lucio

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=b66ccdb4c92100075eeb3caa2560248a@quanstro.net \
    --to=quanstro@quanstro.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).