| www.delorie.com/archives/browse.cgi | search |
| X-Spam-Check-By: | sourceware.org |
| From: | "Dave Korn" <dave DOT korn AT artimi DOT com> |
| To: | <cygwin AT cygwin DOT com> |
| Subject: | RE: 1.5.19-3 parent socket binding remains after closing when spawning child process |
| Date: | Fri, 20 Jan 2006 17:22:50 -0000 |
| MIME-Version: | 1.0 |
| In-Reply-To: | <20060120165308.59367.qmail@web30611.mail.mud.yahoo.com> |
| Message-ID: | <SERRANOWdWhkeLZssJb00000251@SERRANO.CAM.ARTIMI.COM> |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com> |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sourceware.org/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
Martin wrote:
> Well, this is a strange one.
> I open a socket in a parent process, bind it and
> listen.
> I set the socket to close-on-exec with the FD_CLOEXEC
> flag.
> A child process is spawned, which doesn't inherit the
> socket.
> I then close the server socket in the parent process.
> For a laugh, I attempt to connect to the port
> associated with the server socket. I would expect
> this connection request to fail, since I just closed
> the socket. It doesn't.
>
> The attached test case illustrates this.
> Please let me know if I'm doing something wrong.
I can't say why yet, but server_sock is still open in the child. Adding an
explicit "close(server_sock)" just before the call to execlp in the child-side
of the fork clause fixes it. Maybe FD_CLOEXEC isn't implemented or working
properly on cygwin, I haven't looked further yet.
cheers,
DaveK
--
Can't think of a witty .sigline today....
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |