🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

3 total messages Started by Tom Neff Fri, 04 Aug 1989 15:48
Pipeline synchronization - sh vs ksh
#43
Author: Tom Neff
Date: Fri, 04 Aug 1989 15:48
27 lines
1709 bytes
I don't know if the following is a bug or a feature, but it exists. I had
a complex backup script which I was running under the Bourne shell.  The
business end of it ended up evaluating to something like

	find / -print | fgrep -v /tmp/ | fgrep -v /spool/ | \
		pax -wv | compress | team 32k 4 > /dev/rmt/c0s0

so there were about 6 processes in a pipeline.  That 'team' (it's a
buffering copy for tape streaming which has been posted in
comp.sources.misc, and I recommend it highly) itself creates 3 more
processes, so you might say there were 9, but only 6 created by the
shell itself.

Anyway the problem is that control returns to the shell when 'find' is
done but BEFORE the later stages of the pipeline are done!  In particular
the 'pax' and 'compress' and 'team' guys keep going.  I could not find an
effective way to synchronize the shell with the pipeline.

However when I switched to Korn shell, which we also own (I just don't
normally use it for system scripts), lo and behold the shell waits for
ALL the pipeline processes to complete before continuing the script.
So, I am happy for now, but I don't understand what was happening with
/bin/sh.  Can anyone shed some light?

-- 
"We walked on the moon --	((	Tom Neff
	you be polite"		 )) 	tneff@bfmny0.UU.NET
Re: Pipeline synchronization - sh vs ksh
#46
Author: Gordon Stewart
Date: Sat, 05 Aug 1989 00:52
11 lines
938 bytes
Typically, there is one FIFO (a special kind of file that implements
pipes) open for each symbol "|" in a line of shell script.  The flow
is designed in such a way that reading processes have input
and writing processes can write, and nobody will
read on an empty pipe. This means that there will typically be stuff in
all the pipes in a 'sh' command, with the processes runnning
concurrently.
-- 
				{apple, pacbell, hplabs, ucbvax}!well!gors
							gors@well.sf.ca.us
(Doolan) | (Meyer) | (Sierchio) | (Stewart)
Re: Pipeline synchronization - sh vs ksh
#48
Author: Henry Spencer
Date: Sun, 06 Aug 1989 05:17
13 lines
1043 bytes
In article <14511@bfmny0.UUCP> tneff@bfmny0.UUCP (Tom Neff) writes:
>However when I switched to Korn shell, which we also own (I just don't
>normally use it for system scripts), lo and behold the shell waits for
>ALL the pipeline processes to complete before continuing the script.
>So, I am happy for now, but I don't understand what was happening with
>/bin/sh.  Can anyone shed some light?

Historically, getting the parent/child relationships right in long
pipelines has been difficult, and many older Bourne shells don't do it
quite right.  The most modern ones do, I think.
-- 
1961-1969: 8 years of Apollo.  |     Henry Spencer at U of Toronto Zoology
1969-1989: 20 years of nothing.| uunet!attcan!utzoo!henry henry@zoo.toronto.edu
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads