Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!wuarchive!rex!ukma!seismo!dimacs.rutgers.edu!aramis.rutgers.edu!paul.rutgers.edu!njin!princeton!phoenix!pfalstad From: pfalstad@phoenix.princeton.edu (Paul Falstad) Newsgroups: comp.unix.shell Subject: Re: Bash, tar, and broken pipe Message-ID: <58558@localhost.Princeton.EDU> Date: 21 May 91 00:08:49 GMT References: <16345@helios.TAMU.EDU> Sender: gnus@idunno.Princeton.EDU Organization: League For Fighting Chartered Accountancy Lines: 54 byron@archone.tamu.edu (Byron Rakitzis) wrote: >Heinz (heinz@cc.univie.ac.at) sent me some personal mail which I could >not reply to (is there another address I could use to get mail to you, >Heinz?). However, he raised an interesting point: > >Given a pipeline > > foo | tar ft - > >it seems clear that tar must read to EOF in order to determine whether >the tar file that foo writes has come to an end or not. Therefore a >normal instance of > > foo | tar ft - > >should not cause a pipe to break, since tar will always terminate after >foo. I have no clue why tar is exiting prematurely. If anyone can shed >light on the matter, I think Heinz and I would appreciate it. (Servus, >Heinz!) I don't know the tarfile format, since I don't have source, but let's see: % ls a b c % tar cvf foo a a/ a/b a/c % tar tvf foo drwxr-xr-x pfalstad/student 0 May 20 20:05 1991 a/ -rw-r--r-- pfalstad/student 29 May 20 20:05 1991 a/b -rw-r--r-- pfalstad/student 29 May 20 20:05 1991 a/c % ls -l foo -rw-r--r-- 1 pfalstad 10244 May 20 20:13 foo (that's quite a big file for only 58 bytes of data. Must be lots of padding at the end) % cat /etc/motd /usr/dict/words >>foo % tar tvf foo drwxr-xr-x pfalstad/student 0 May 20 20:05 1991 a/ -rw-r--r-- pfalstad/student 29 May 20 20:05 1991 a/b -rw-r--r-- pfalstad/student 29 May 20 20:05 1991 a/c % man tar | sed -n 242,246p If there are multiple archive files on a tape, each is separated from the following one by an EOF marker. tar does not read the EOF mark on the tape after it finishes reading an archive file because tar looks for a special header to decide when it has reached the end of the archive. Now if % ... -- Paul Falstad | 10 PRINT "PRINCETON CS" pfalstad@phoenix.princeton.edu | 20 GOTO 10