Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!sdd.hp.com!samsung!uunet!mcsun!hp4nl!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.questions Subject: Re: csh reading from stdin Message-ID: <7370@star.cs.vu.nl> Date: 23 Aug 90 15:24:25 GMT References: Sender: news@cs.vu.nl Reply-To: maart@cs.vu.nl (Maarten Litmaath) Organization: VU Dept. of Computer Science, Amsterdam, The Netherlands Lines: 23 In article , glenn@wacsvax.uwa.oz (Glenn Huxtable) writes: )... )[SunOS 4.0.3] ) ) set line=$< ) # decide which filter ) (echo $line ; cat) | $FILTER ) )this resulted in two copies of the first line. 1) The bug is in `cat': it reads the file using mmap(2), blindly assuming you want to start reading at byte offset 0. :-( Probably fixed in SunOS 4.1. You can't mmap() a pipe, so things work correctly if stdin is a pipe, as cat must use read(2) in that case. 2) Your scheme depends on csh reading the line 1 byte at a time (normally file IO is _block-buffered_); though your implicit assumption appears to be correct indeed, the manual doesn't guarantee it. :-( -- "[Your C code] seems about as portable as the Rock of Gibraltar." (Wayne Throop)