This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
Cygwin-Windows pipe communication
- From: Ajay Nerurkar <ajaynerurkar at yahoo dot com>
- To: cygwin at cygwin dot com
- Date: Thu, 17 Jul 2003 19:06:35 -0700 (PDT)
- Subject: Cygwin-Windows pipe communication
I have this scenario:
The parent process forks and execs a child process which is a Windows
program. The child's stdin is connected (via a dup2) to a pipe that
it uses to get input from the parent and writes it to a file.
The parent writes data to the pipe and then closes its end of the
pipe, but I find that the child hangs around waiting for more data. I
don't see this problem if I exec a Cygwin process to do the same
thing instead.
It seems that a pipe close by the parent is not recognized by a child
Windows process. So, I tried a little experiment.
Let's assume the parent writes to fd[1]. Before the child execs, it
closes its copy of fd[1] and does dup2(fd[0], 0). Now, if I set the
close_on_exec flag on fd[1] IN THE PARENT before the fork, all is
fine -- the child knows that the parent has closed the other end of
the pipe. However, if I set that flag IN THE CHILD before it execs,
the problem persists.
Are there any known limitations in the Cygwin pipe implementation
when the pipe is between a Cygwin process and a Windows one? Why does
setting the close_on_exec flag in the parent get rid of the problem?
And why doesn't setting it in the child work?
Ajay
__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
--
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/