[TUHS] Excise process from a pipe

Warren Toomey wkt at tuhs.org
Thu Jul 10 14:52:23 AEST 2014


On Wed, Jul 09, 2014 at 10:49:22PM -0400, Doug McIlroy wrote:
> It's easy for a process to insert a new process into a
> pipeline either upstream or downstream. Was there ever a 
> flavor of Unix in which a process could excise itself
> from a pipeline without breaking the pipeline?

If in the middle of a pipeline, all I can think of is:

	close fd 0 and fd 1
	dup() read end of pipe 1 to be stdin (fd 0)
	dup() write end of pipe 2 to be stdout (fd 1)
	exec("/bin/cat")

Cheers, Warren



More information about the TUHS mailing list