how to use pipes (was: Re: system() question)

L. Scott Emmons emmonsl at athena.ecs.csus.edu
Fri Mar 8 04:05:31 AEST 1991


In article <5866:Mar604:22:3791 at kramden.acf.nyu.edu> brnstnd at kramden.acf.nyu.edu (Dan Bernstein) writes:
>This is, of course, because you aren't waiting for the child to finish.


Actually, it does finish...the child closes the pipeline down when it is done.
The read() reads unless eof, which it only returns when the write end of the
pipeline is closed (it blocks if the pipeline is open with no data in it).
I just did it all implicitly...If anyone can come up with an example where
this wouldn't work please let me know. (except the obvious, where the child
doesn't close the pipe, of course...but then, you are changing the
environment of the usage, of course)

Remember also, that I ignored all the return codes for simplicity in the
examples.

Check out my second version, it works the same, but is easier to see how I
implemented this.

			L. Scott Emmons
			---------------
	emmons at csus.csus.edu  <or>  ...[ucbvax]!ucdavis!csus!emmons
		Packet: kc6nfp at kg6xx.#nocal.ca.usa.na



More information about the Comp.unix.programmer mailing list