Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Sep 1998 19:56:25 +0200
From:      Tor.Egge@fast.no
To:        info@highwind.com
Cc:        tlambert@primenet.com, eischen@vigrid.com, freebsd-current@FreeBSD.ORG
Subject:   Re: Thread Problems
Message-ID:  <199809101756.TAA12440@midten.fast.no>
In-Reply-To: Your message of "Thu, 10 Sep 1998 09:46:24 -0400 (EDT)"
References:  <199809101346.JAA16724@highwind.com>

next in thread | previous in thread | raw e-mail | index | archive | help
> 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199809101756.TAA12440>