Mail Archives: cygwin-developers/2002/07/13/15:50:29

Mailing-List: contact cygwin-developers-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-developers-subscribe AT cygwin DOT com>
List-Archive: <>
List-Post: <mailto:cygwin-developers AT cygwin DOT com>
List-Help: <mailto:cygwin-developers-help AT cygwin DOT com>, <>
Sender: cygwin-developers-owner AT cygwin DOT com
Delivered-To: mailing list cygwin-developers AT cygwin DOT com
Date: Sat, 13 Jul 2002 15:46:37 -0400 (EDT)
From: David Euresti <davie AT MIT DOT EDU>
X-X-Sender: <davie AT this>
To: <cygwin-developers AT cygwin DOT com>
Subject: How about this for passing file descriptors?
Message-ID: <Pine.LNX.4.33.0207131534200.3194-100000@this>
MIME-Version: 1.0

	I'm still thinking about this problem.  Since my first solution
was shot down because of my use of the cygserver.

So here's a way to do it without the cygserver.  
P1 wants to send FD1 to P2

#1 P1 calls sendmsg with Data
	A.  Extract handle from FD1, H1.
	B.  Duplicate H1 -> H1bis
	C.  Create an Event E1
	D.  Create header as follows:
		HANDLE hDescriptor; = H1bis
		HANDLEINFO hi;  <--- This is obviously more.
		HANDLE HEvent;  = E1
		int Process;
	E.  Spawn a new thread to wait on event
		i.  When event is signalled close H1bis, then exit Thread.
	F.  Send header + Data

#2 P2 calls recvmsg
	A.  Get header + Data
	B.  Duplicate HEvent into current process -> E2
	C.  Duplicate hDescriptor into current process -> H2
	D.  Call SetEvent on E2
	E.  Turn H2 and HANDLEINFO into FD2
	F.  Return data and FD2

So this will work when the sender wants to close the FD after sending it.  
Because a duplicate of the Handle is still hanging around in Duplicate 

It will not work if the sender exits after sending it.  Or rather there 
will be a race condition.  Is there a way to keep the process alive for a 
little while?  At least like 10 seconds or until the Event is signalled?

Note: If this message is confusing search for File Descriptor in 
cygwin-patches where i posted a lot of info.

Let me know what you think,

- Raw text -

  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019