Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!sri-spam!nike!ucbcad!ucbvax!ulysses!ekrell From: ekrell@ulysses.UUCP (Eduardo Krell) Newsgroups: net.unix-wizards Subject: Re: comm '! sort file1' '! sort file2' Message-ID: <1422@ulysses.UUCP> Date: Wed, 8-Oct-86 08:40:53 EDT Article-I.D.: ulysses.1422 Posted: Wed Oct 8 08:40:53 1986 Date-Received: Wed, 8-Oct-86 22:46:03 EDT References: <6846@elsie.UUCP> <830003@hpcnoe.UUCP> <35@pixutl.UUCP> <3724@umcp-cs.UUCP> Reply-To: ekrell@ulysses (Eduardo Krell) Organization: AT&T Bell Laboratories, Murray Hill Lines: 26 I just implemented this feature on SVR3 by adding "seekable pipes". What I really did was to port the /dev/fd hack from V8 and I also added a new file control command to "block on eof". When a process opens a file for reading with this flag, an attempt to read() past the end of file will block provided some other process is writing to that file. When data is written to the file, the reader will awake and continue as normal. Very similar to pipes. When you type (in ksh) "diff <(sort file1) <(sort file2)", the following happens 1) a file is created in /tmp. it is opened once for reading and once for writing. an fcntl() is done to add the "block on eof" attribute. It is then unlink()ed. 2) A pipe is created to read from "sort file1". Say the reader file descriptor is 3. The "<(sort file2)" argument is replaced by "/dev/fd/3". Same thing happens to the second argument. 3) When diff opens /dev/fd/3, it will be actually reading from the pipe. seek()s are ok since it is actually reading from a file in /tmp. 4) Since the file was unlink()ed, it will go away after both sort and diff finish. -- Eduardo Krell AT&T Bell Laboratories, Murray Hill {ihnp4,seismo,ucbvax}!ulysses!ekrell