Mailing-List: contact cygwin-developers-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , 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 X-X-Sender: To: Subject: How about this for passing file descriptors? Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Hello, 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 Handle. 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, David