This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Socket Handles duplicated twice after fork


Corinna says:

>The handles are only inherited if they are explicitly marked as
>inheritable.  The Cygwin code lives for a long time now under the
>assumption that sockets aren't inheritable if they aren't
>explicitely set to be inheritable (see, fdsock()).

Hmmm.  I think there's a wrong assumption here as you mentioned.
MSDN says,;EN-US;q150523

Under Windows NT and Windows 2000, socket handles are inheritable by
default. This feature is often used by a process that wants to spawn a
child process and have the child process interact with the remote
application on the other end of the connection.

Windows 9x differs from Windows NT/Windows 2000 in the following manner:
Socket handles are not inheritable when created. To ensure that a child
process can obtain and use a socket handle created in the parent, the
handle must be explicitly duplicated using the Win32 API DuplicateHandle.
Set the bInheritHandle parameter of the API to TRUE.

Therefore, on Win2k, you are letting them be inherited.  So the probably
the right solution is to always inherit, or to always duplicate, but never
do both.  Although I don't know maybe we want to inherit in Win2k and
Duplicate in Win9x.  (I hate this whole windows versions things)

Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]