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/