Patch to pass file descriptors

Corinna Vinschen
Wed Jul 3 04:41:00 GMT 2002

On Wed, Jul 03, 2002 at 07:59:59PM +0900, Dmitry Timoshkov wrote:
> Hello all.
> Why not implement passing file descriptors in the following way:
> Somewhere in the structure passed to sendmsg send a handle of
> the calling process created with
> OpenProcess(PROCESS_DUP_HANDLE, FALSE, GetCurrentProcessId());
> OpenProcess will always succed, since the caller is current process.
> recvmsg implementation will just use that process handle
> for the DuplicateHandle call.

recvmsg is in another process.  The open handle is only valid in
the source process.  It would have to be duplicated for the receiving
process using DuplicateHandle(src, target) which only works if
the duplicating process has already PROCESS_DUP_HANDLE access on
the other process.  Therefore the Cygwin internal descriptor
passing code only works if one of the processes is a privileged
process (being member of the admins group is sufficient here).

That means basically, if one needs to pass descriptors between
two non-privileged processes, it still requires a cygserver solution.

For the records:

Please keep in mind that I'm *not* against a cygserver solution.
It's just that I'm still trying to get as much functionality done
in the DLL itself w/o needing the cygserver.  The cygserver should
be only the resort for functionality which can't get implemented
with just the dll.  It's not the panacea to implement every new
functionality w/o having to think about a stand-alone solution.


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                      
Red Hat, Inc.

More information about the Cygwin-patches mailing list