Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!iuvax!cica!tut.cis.ohio-state.edu!ucsd!sdd.hp.com!hplabs!nsc!daisy!marlon From: marlon@daisy.UUCP (Marlon Pearson) Newsgroups: comp.unix.questions Subject: Re: parent & child reading stdin Message-ID: <48@daisy.UUCP> Date: 2 May 90 16:38:24 GMT References: <46@daisy.UUCP> <7940@jpl-devvax.JPL.NASA.GOV> Reply-To: marlon@daisy.com (Marlon Pearson) Distribution: usa Organization: Daisy/Cadnetix Lines: 40 :In article <46@daisy.UUCP> marlon@daisy.UUCP (Marlon Pearson) writes: :: My understanding is that you can't guarantee who gets which bytes when :: you have two processes reading from the stdin at the same time. Is it a :: bad idea if I have a parent process that will read the first N bytes and then :: fork and exec a child process and let it read the rest of stdin? I have tried :: this with out doing any dups or pipes or such for passing bytes from the :: parent to the child. The child inherits the stdin from its parent and reads :: it fine. As I said, it seems to work and makes sense but is it the "correct" :: way of doing it. :It better be correct, since the shells do that all day long. :The distinction to be made is that, since "correct" programs are using the :fork as a synchronization point, they are NOT, in fact, "two processes :reading from stdin at the same time." :Though I don't know what you mean by your antepenultimate sentence. In :what way are you using stdin to pass bytes from the parent to the child? :That doesn't fit in with the rest of what you are asking. :Larry Wall Larry, Thanks for the response. As to the third from the end sentence. I understand that it is a fairly common practice when passing info between a parent and child to set up a pipe or pipes where one process writes to the pipe and the other reads from it. So, I thought this may be an alternative to what I current have working. The parent would read from stdin and after it had consumed the first N bytes it would simply pass the remaining byte stream to the child via writing to the pipe. The child would read from the pipe instead of stdin. Marlon -- =========================================== Marlon {nsc,atari,pyramid,uunet}!daisy!marlon