Re: children not getting eof from pipe



Jim Gibson <jgibson@xxxxxxxxxxxxxxxxx> wrote:
> In article <1119238835.726861.273020@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
> <kspecial@xxxxxxxxxxxxx> wrote:

> >
> > $oldpid = $$;
> > for (undef($num); $num < $forks; $num++) {
> > $read = $fd[$num][0];
> > $write = $fd[$num][1];
> > if (fork) { close($read); } else { close($write); last; }
> > }
> >
....
> > }
> > else {
> > while(!(eof($read))) {
> > my $data = readline($read);
>
> The value of $read here is incorrect except for the last child. All
> children are reading from the same pipe, the last one created.

It is hard to tell from the weird code, but it does look like each
child has a different $read at the time they "last" out of the for
loop.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
.



Relevant Pages

  • Re: Thread question
    ... Any threads that are started by the main thread can start child ... >>#2 is incorrect. ... >>continue to execute. ...
    (comp.lang.java.programmer)
  • Re: newbus flaw
    ... John-Mark Gurney writes: ... > You are incorrect in assuming you can't find out if another child already ... Usually this is a problem of properly allocating resources so ... > that you know the other child exists. ...
    (freebsd-arch)
  • Re: defunct processes dont always go away when parent does waitpid(-1)
    ... > Rob Y wrote: ... >> should clean them all up, ... it takes only one child. ... That would be incorrect. ...
    (comp.unix.aix)
  • Re: unix pipe problems
    ... > '&buffer' is incorrect. ... > You never initialized 'wordsize' in the child. ... that the child process finishes before the parent can ever send ...
    (comp.unix.programmer)
  • Re: reading
    ... >> of reading INSTRUCTION called Phonics and Whole-Word? ... >> As other people have commented, there is not much evidence that phonics is ... > And if a child who has recently learned to read is called ...
    (misc.kids)