Pipeline synchronization - sh vs ksh

Tom Neff tneff at bfmny0.UUCP
Sat Aug 5 01:48:58 AEST 1989


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 at bfmny0.UU.NET



More information about the Comp.bugs.sys5 mailing list