From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: To: 9fans@9fans.net From: erik quanstrom Date: Thu, 27 Nov 2008 09:54:39 -0500 In-Reply-To: <140e7ec30811262349m764d4166kdd44141bf6afc2a3@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] APE and listen(2B) Topicbox-Message-UUID: 535ddeb6-ead4-11e9-9d60-3106f5b1d025 > On Thu, Nov 27, 2008 at 1:35 PM, 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