X-Spam-Check-By: sourceware.org Message-Id: <200706230306.l5N36n9o006571@chi.hcst.net> Date: Sat, 23 Jun 2007 03:06:49 -0000 To: Subject: Re: Socket inheritance with fork/dup2/exec From: "Jim Powers" X-Mailer: TWIG 2.7.4 In-Reply-To: <20070622072042.GG7379@calimero.vinschen.de> X-Client-IP: 12.216.112.235 X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Corinna, I took your suggestion and downloaded the latest sanpshot (cygwin1- 20070616.dll) and that fixed the problem. The Win32 version of the client compiled with VC8 now works fine. Thanks!! Jim Corinna Vinschen said: > On Jun 21 22:45, Jim Powers wrote: > > Hi, > > > > I am redirecting the stdout of a child process to a socket via the standard > > fork/dup2/exec paradigm and then reading and displaying the output. > > > > This works fine if the exec'd child process is compiled using gcc under > > cygwin. However, it fails with an "Invalid file handle" error when compiled > > using VC8 under windows. > > > > I've included both the parent and child code below. > > > > I am running cygwin 1.5.24 and gcc3.4.4. > > This is almost certainly a drawback of the method used for duplicating > sockets to child processes used in Cygwin 1.5.24 and before > (WSADuplicateSocket/WSASocket). This only works reliable if the child > knows that the descriptor is a socket. Usually server applications > using sockets don't duplicate the socket to the child processes, but > instead use pipes or pseudo terminals on the local connection, so that's > not a standard problem. > > However, the next version of Cygwin will use standard DuplicateHandle > calls as for normal file handles. Consequentially your > your test application appears to work with a Cygwin built from CVS: > > $ ./sock-cyg-win-parent ./sock-cyg-win-child.exe > hellohellohellohellohello^C > > You could try a developer snapshot from http://cygwin.com/snapshots/ > > As a workaround for Cygwin 1.5.x, use pipes, as already noted, or pseudo > terminals. > > > Corinna > > -- > Corinna Vinschen Please, send mails regarding Cygwin to > Cygwin Project Co-Leader cygwin AT cygwin DOT com > Red Hat > > -- > Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple > Problem reports: http://cygwin.com/problems.html > Documentation: http://cygwin.com/docs.html > FAQ: http://cygwin.com/faq/ > -- Jim Powers Powers Consulting Services, Inc. jim DOT powers AT powers-consulting DOT com 937-271-5523 -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/