From owner-freebsd-current Thu Sep 10 10:57:11 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id KAA17023 for freebsd-current-outgoing; Thu, 10 Sep 1998 10:57:11 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from midten.fast.no (midten.fast.no [195.139.251.11]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id KAA17000 for ; Thu, 10 Sep 1998 10:57:06 -0700 (PDT) (envelope-from tegge@fast.no) Received: from fast.no (IDENT:tegge@midten.fast.no [195.139.251.11]) by midten.fast.no (8.9.1/8.9.1) with ESMTP id TAA12440; Thu, 10 Sep 1998 19:56:25 +0200 (CEST) Message-Id: <199809101756.TAA12440@midten.fast.no> To: info@highwind.com Cc: tlambert@primenet.com, eischen@vigrid.com, freebsd-current@FreeBSD.ORG Subject: Re: Thread Problems From: Tor.Egge@fast.no In-Reply-To: Your message of "Thu, 10 Sep 1998 09:46:24 -0400 (EDT)" References: <199809101346.JAA16724@highwind.com> X-Mailer: Mew version 1.70 on Emacs 19.34.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Thu, 10 Sep 1998 19:56:25 +0200 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > It'll bind to port 10000, and start printing messages on stdout, then > from another window: "telnet localhost 10000". You'll see the main() > thread STOP printing. ONLY the accept() thread will continue to work. > > Help would be greatly appreciated... Using fork()/exec() in threaded programs is not trivial at all. The call to execve() in the child process clears the nonblocking flag on the accept socket. This is correct, given that the file descriptor was not explicitly marked as nonblocking in the given program. A workaround would be - change execve() to only clear the nonblocking flag on file descriptors where the close-on-exec flag is 0 - change the test program to set the close-on-exec flag on the accept socket. (Most file descriptors should have the close-on-exec flag set) I believe forking a child process before starting any threads and using that as a proxy parent process for any future child processes is a normal way to deal with this kind of problems. - Tor Egge To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message