delorie.com/archives/browse.cgi | search |
X-Spam-Check-By: | sourceware.org |
Message-ID: | <20060120165308.59367.qmail@web30611.mail.mud.yahoo.com> |
Date: | Fri, 20 Jan 2006 11:53:08 -0500 (EST) |
From: | Martin <linkscrazy AT yahoo DOT com> |
Subject: | 1.5.19-3 parent socket binding remains after closing when spawning child process |
To: | cygwin AT cygwin DOT com |
MIME-Version: | 1.0 |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
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 |
Note-from-DJ: | This may be spam |
--0-138723249-1137775988=:59061 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Content-Id: Content-Disposition: inline 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. Thanks for your help. Martin __________________________________________________________ Find your next car at http://autos.yahoo.ca --0-138723249-1137775988=:59061 Content-Type: application/octet-stream; name="test1.cpp" Content-Transfer-Encoding: base64 Content-Description: 317282840-test1.cpp Content-Disposition: attachment; filename="test1.cpp" I2luY2x1ZGUgPHN0ZGxpYi5oPgojaW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1 ZGUgPHVuaXN0ZC5oPgojaW5jbHVkZSA8c3lzL3NlbGVjdC5oPgojaW5jbHVk ZSA8c3lzL3NvY2tldC5oPgojaW5jbHVkZSA8c3lzL3R5cGVzLmg+CiNpb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b2NrOwogICAgc29jayA9IHNvY2tldChBRl9JTkVU LCBTT0NLX1NUUkVBTSwgMCk7CgogICAgc29ja2FkZHJfaW4gc2luOwogICAg c2luLnNpbl9mYW1pbHkgPSBBRl9JTkVUOwogICAgc2luLnNpbl9hZGRyLnNf YWRkciA9IGh0b25sKElOQUREUl9MT09QQkFDSyk7CiAgICBzaW4uc2luX3Bv cnQgPSBodG9ucyhzaG9ydCg4ODg4KSk7CgogICAgaWYgKGNvbm5lY3Qoc29j aywgKHNvY2thZGRyKikmc2luLCBzaXplb2Yoc2luKSkgPT0gMCkgewogICAg ICBwcmludGYoInNlcnZlciBwcm9jZXNzIGNvbm5lY3RlZFxuIik7CiAgICB9 IGVsc2UgewogICAgICBwZXJyb3IoImNvbm5lY3Q6ICIpOwogICAgfQogICAg CiAgICBleGl0KDApOwogIH0KfQo= --0-138723249-1137775988=:59061 Content-Type: text/plain; charset=us-ascii -- 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/ --0-138723249-1137775988=:59061--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |