delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/07/17/22:06:57

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <20030718020635.45362.qmail@web12507.mail.yahoo.com>
Date: Thu, 17 Jul 2003 19:06:35 -0700 (PDT)
From: Ajay Nerurkar <ajaynerurkar AT yahoo DOT com>
Subject: Cygwin-Windows pipe communication
To: cygwin AT cygwin DOT com
MIME-Version: 1.0

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019