[corinna-cygwin@cygwin.com: Re: ENOTSOCK errors with cygwin dll 1.3.21 and 1.3.22]

Pierre A. Humblet Pierre.Humblet@ieee.org
Thu May 29 16:17:00 GMT 2003

Corinna Vinschen wrote:

>  Btw., on *my* box
> the problem happens in *both* cases, started from cmd as well as from
> tcsh.

OK, that kills the cygheap hypothesis.
I have confirmed the problem stems from access to the current process;
 it disappears when Everyone has access.
So we really know the root cause and the RevertToSelf solution is 
completely appropriate. 
That doesn't explain why it worked for Jason when starting from Windows. 
Perhaps his system gives wider access than Cygwin's __sec_user() does.

Glad it's over. The only embellishment I see is to move the 
fixup_before_fork_exec() call inside the winsock2_active clause, 
it is useless otherwise. Something like a self contained block.
Oops, while writing the snippet I noticed a bug. Fixed below.
if (winsock2_active)
      fhs->set_io_handle (get_io_handle ())
      if (cygheap->user.issetuid ()) 
        RevertToSelf ();
      fhs->fixup_before_fork_exec (GetCurrentProcessId ());
      if (cygheap->user.issetuid ())
        ImpersonateLoggedOnUser (cygheap->user.token);
      fhs->fixup_after_fork (hMainProc);
      if (fhs->get_io_handle() != (HANDLE) INVALID_SOCKET)
	return 0;
      debug_printf ("WSADuplicateSocket failed, trying DuplicateHandle");


More information about the Cygwin-developers mailing list