[comp.unix.i386] Pipeline synchronization - sh vs ksh

tneff@bfmny0.UUCP (Tom Neff) (08/04/89)

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