fixup_after_fork (NULL)

Corinna Vinschen corinna-cygwin@cygwin.com
Fri Feb 28 12:41:00 GMT 2020


On Feb 27 17:24, Ken Brown wrote:
> fhandler_socket_wsock::fixup_after_exec and
> fhandler_socket_unix::fixup_after_exec call fixup_after_fork (NULL), which
> would seem to lead to calls to DuplicateHandle with first argument NULL.  I
> can't find any documentation that says this is legal.  What do these calls
> do?

They fail with ERROR_INVALID_HANDLE.

I checked the commit history and it turned out that this has been
introduced with commit 528060195ca6c back in 2002.

In fhandler_socket_wsock it has no negative impact.  fixup_after_exec
calls fixup_after_fork *only* on need_fixup_before(), that is, if the
handle was some of the special LSP handles, so the socket handle has to
be created by WSADuplicateSocket/WSASocket.  In that case the parent
handle isn't needed.

Same in case of fhandler_pty_slave.  Its fixup_after_fork doesn't
require the parent handle at all.

In case of fhandler_socket_unix, this was most likely a straight
copy/paste or developer-didn't-actually-think-about-it-error.
I fear it was the latter.  I have to start thinking about it...


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-developers/attachments/20200228/cd92161a/attachment.sig>


More information about the Cygwin-developers mailing list