This is the mail archive of the
mailing list for the Cygwin project.
Re: Socket Handles duplicated twice after fork
- From: David E Euresti <davie at MIT dot EDU>
- To: <cygwin at cygwin dot com>
- Date: Tue, 4 Jun 2002 10:59:00 -0400 (EDT)
- Subject: Re: Socket Handles duplicated twice after fork
Ah the additional handles come from this.
fork call CreateProcess as follows
rc = CreateProcess (myself->progname, /* image to run */
myself->progname, /* what we send in arg0 */
TRUE, /* inherit handles from parent */
NULL, /* environment filled in later */
0, /* use current drive/directory */
notice the inherit handles from parent,
WSADuplicateSocketA (get_socket (), win_proc_id, prot_info_ptr)
now this doesn't actually create a new handle. It just stores the info in
but fixup_after_fork calls,
new_sock = WSASocketA (FROM_PROTOCOL_INFO,
prot_info_ptr, 0, 0)
and this creates the new handle,
then set_io_handle ((HANDLE) new_sock);
and the old handle disappears into oblivion.
I don't know why it's written this way. It would seem easier to just use
the same Duplicated handle from the CreateProcess. I'm thinking that
maybe on Win9x it doesn't work the same (but I haven't even tested it)
Hope this helps.
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html