Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Sep 1998 07:58:12 +0100
From:      Mark Ovens <marko@uk.radan.com>
To:        Leo Papandreou <leo@talcom.net>
Cc:        questions@FreeBSD.ORG, freebsd-users@freebsd-uk.eu.org
Subject:   Re: Help needed with fork(), pipe() & dup2()
Message-ID:  <35F77884.E4FEAA21@uk.radan.com>
References:  <35F6EE38.7DC97F21@uk.radan.com> <19980909182820.16714@talcom.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Leo Papandreou wrote:
> 
> 
> gets() works fine beyond the initial warning.
> 
> I dont know why your program is failing but I do think that you are
> making an unwarranted assumption about the order that the child and
> its parent will execute. It seems possible to me that the child may
> see NULL at gets() before files() executes. Its not a good idea to
> place bets on the order that processes are scheduled.

Ah, that makes sense. In order to prove this could I add sleep() or
usleep() before the while(gets())? or would any data in the pipe be
lost if there was nothing to read it immediately?. I realize this
would be a poor real life solution but it would be a quick way to test
the theory.


> 
> Richard Stevens' "Advanced Programming the UNIX Environment" has a
> couple of parent/child synchronization routines that are useful. He
> has a web site (sorry, dont have the URL) and the site archives the
> source code that goes with the book.

I'll see if I can find it.

-- 
  When everything's coming your way, you're in the wrong lane.

Mark Ovens, CNC Applications Engineer, Radan Computational Ltd
Sheet Metal CAD/CAM Solutions
mailto:marko@uk.radan.com    http://www.radan.com

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?35F77884.E4FEAA21>