Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!spool.mu.edu!agate!usenet.ins.cwru.edu!odin!chet From: chet@odin.INS.CWRU.Edu (Chet Ramey) Newsgroups: comp.unix.shell Subject: Re: Bash, tar, and broken pipe Message-ID: <1991May22.192914.22142@usenet.ins.cwru.edu> Date: 22 May 91 19:29:14 GMT Article-I.D.: usenet.1991May22.192914.22142 References: <16345@helios.TAMU.EDU> Sender: news@usenet.ins.cwru.edu Reply-To: chet@po.CWRU.Edu Organization: Yoyodyne Propulsion Systems, Inc. Lines: 56 Nntp-Posting-Host: odin.ins.cwru.edu In article heinz@cc.univie.ac.at () writes: >This does not explain the broken pipe, though. I tried the following: > > cat | more > >and killed 'more' by pressing 'q' at the first prompt (so more terminates >first). No 'Broken Pipe'. I guess I'll take a shot at this one. First of all, other shells (csh and ksh for sure) special-case the message printed when a child process dies due to an interrupt (SIGINT) or a broken pipe (SIGPIPE). Bash does not skip over SIGPIPE, hence the unexpected `Broken Pipe' message. >Then I tried: > > echo Hallo | (sleep 10; more) # first process terminates first, since > 'Hallo' should fit into the pipe's buffer > >No 'Broken Pipe' either. Try slc2$ cat /etc/termcap | sleep 1 Broken pipe (I also get the `Broken Pipe' message when I do `cat /etc/termcap | more' and immediately hit `q'.) The broken pipe/SIGPIPE/EPIPE happens to the *first* process in a pipeline; the error occurs when an attempt is made to write on a pipe when no process has it open for reading. The process must exit due to the SIGPIPE, by the way -- no message will be printed if it catches the SIGPIPE and calls exit(), unless the fatal signal handler is coded like this: fatal(sig) int sig; { cleanup(); _exit(128+sig); } >Maybe I should take the time and hack up the source code of bash, >but I'm not sure if it's worth the effort. It's a several-minute job, to be sure ;-) Chet -- Chet Ramey Internet: chet@po.CWRU.Edu Case Western Reserve University NeXT Mail: chet@macbeth.INS.CWRU.Edu ``Now, somehow we've brought our sins back physically -- and they're pissed.''