This is the mail archive of the
mailing list for the Cygwin project.
Re: Socket inheritance with fork/dup2/exec
- From: "Jim Powers" <jim dot powers at powers-consulting dot com>
- To: <cygwin at cygwin dot com>
- Date: Sat, 23 Jun 2007 03:06:49 -0000
- Subject: Re: Socket inheritance with fork/dup2/exec
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.
Corinna Vinschen <email@example.com> said:
> On Jun 21 22:45, Jim Powers wrote:
> > Hi,
> > I am redirecting the stdout of a child process to a socket via the
> > 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
> > 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
> 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
> 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/
Powers Consulting Services, Inc.
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html