From owner-freebsd-questions Wed Sep 9 23:59:00 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id XAA12616 for freebsd-questions-outgoing; Wed, 9 Sep 1998 23:59:00 -0700 (PDT) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from post.mail.demon.net (post-20.mail.demon.net [194.217.242.27]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id XAA12611 for ; Wed, 9 Sep 1998 23:58:59 -0700 (PDT) (envelope-from marko@uk.radan.com) Received: from [158.152.75.22] (helo=uk.radan.com) by post.mail.demon.net with smtp (Exim 2.02 #1) id 0zH0gq-0002xo-00; Thu, 10 Sep 1998 06:58:49 +0000 Organisation: Radan Computational Ltd., Bath, UK. Phone: +44-1225-320320 Fax: +44-1225-320311 Received: from beavis.uk.radan.com (beavis [193.114.228.122]) by uk.radan.com (8.6.10/8.6.10) with SMTP id HAA01276; Thu, 10 Sep 1998 07:58:21 +0100 Received: from uk.radan.com (gppsun4) by beavis.uk.radan.com (4.1/SMI-4.1) id AA00958; Thu, 10 Sep 98 07:58:20 BST Message-Id: <35F77884.E4FEAA21@uk.radan.com> Date: Thu, 10 Sep 1998 07:58:12 +0100 From: Mark Ovens Organization: Radan Computational Ltd X-Mailer: Mozilla 4.03 [en] (X11; I; SunOS 4.1.3_U1 sun4m) Mime-Version: 1.0 To: Leo Papandreou Cc: questions@FreeBSD.ORG, freebsd-users@freebsd-uk.eu.org Subject: Re: Help needed with fork(), pipe() & dup2() References: <35F6EE38.7DC97F21@uk.radan.com> <19980909182820.16714@talcom.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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