Re: Rendezvous between related processes
From: Eric Sosman (Eric.Sosman_at_sun.com)
Date: Thu, 24 Jun 2004 13:24:26 -0400
Olivier Parisy wrote:
> Barry Margolin wrote:
>> It shouldn't matter when you do the dup2's.
> Is that so ? So, if a process starts reading on a pipe
> whose other end isn't connected to the standard output
> of a subprocess, it should just block, and not get an EOF ?
> And, after the dup2() is performed, reading should resume
> properly ?
The dup2() really has nothing to do with what the read()
sees. The read() will wait until somebody does a write(),
and it doesn't matter what file descriptor number is used
for the write(). You could call dup2() ninety-nine times
and give yourself a hundred file descriptors all open on
the writing end of the pipe; the read() will receive anything
you write() to any of them.
> Then I may have fixed my problem as a side effect
> of another bug pinning :-)
>> What do you mean by "properly set up theirs ends of pipes"? Once you
>> create the pipe, there's no special setup required.
> I just mean "to use dup2() so that they can be read or written
> to using standard IO". Would I read/write directly to the proper
> descriptors, no setup would be necessary, indeed.