Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site drivax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!cmcl2!philabs!prls!amdimage!amdcad!amdahl!drivax!alan From: alan@drivax.UUCP (Alan Fargusson) Newsgroups: net.unix-wizards Subject: Re: tar fs copy Message-ID: <233@drivax.UUCP> Date: Mon, 16-Sep-85 01:45:04 EDT Article-I.D.: drivax.233 Posted: Mon Sep 16 01:45:04 1985 Date-Received: Wed, 18-Sep-85 04:05:24 EDT References: <832@burl.UUCP> <221@drivax.UUCP> <842@burl.UUCP> <240@investor.UUCP> Organization: Digital Research, Monterey, CA Lines: 27 > > Wait a minute! I have a Bourne shell script called cphier which contains the > following and runs fine. > > if [ $# -ne 2 ] > then > echo usage: cphier frompath topath > fi > exec tar cf - $1 | (cd $2; tar xf - ) > > What am I doing wrong? It doesn't always fail. The problem is that sh(1) makes the first tar a child of the second tar. If the second tar has to create a directory it does a fork/exec of mkdir, then waits for all of its children to die, including the first tar. Now if the first tar is nearly finished then it will write its output to the pipe and exit, which allows the second tar to continue. However, if the first tar has to write more than what will fit in the pipe then the whole mess hangs up, because the first tar is waiting for the second tar to read from the pipe, and the second tar is waiting for the first tar to exit. -- Alan Fargusson. { ihnp4, amdahl, mot }!drivax!alan Brought to you by Super Global Mega Corp .com