From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5796 invoked from network); 17 Apr 2000 10:47:57 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 17 Apr 2000 10:47:57 -0000 Received: (qmail 4372 invoked by alias); 17 Apr 2000 10:47:46 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10789 Received: (qmail 4331 invoked from network); 17 Apr 2000 10:47:41 -0000 Date: Mon, 17 Apr 2000 11:47:12 +0100 From: Peter Stephenson Subject: PATCH: Re: FIFOs In-reply-to: "Your message of Mon, 17 Apr 2000 14:03:47 +0400." <000001bfa854$38e16cc0$21c9ca95@mow.siemens.ru> To: zsh-workers@sunsite.auc.dk (Zsh hackers list) Message-id: <0FT5004HXPYN6P@la-la.cambridgesiliconradio.com> Content-transfer-encoding: 7BIT > O.K., if for whatever reason the FIFO is not possible, it nice to have > it mentioned in manual. To document current behaviour (passing > /dev/fd/... instead of FIFO) and mention, that it may not work with some > programs, a la sudo. Index: Doc/Zsh/expn.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/expn.yo,v retrieving revision 1.6 diff -u -r1.6 expn.yo --- Doc/Zsh/expn.yo 2000/04/14 13:07:58 1.6 +++ Doc/Zsh/expn.yo 2000/04/17 10:44:33 @@ -278,13 +278,13 @@ `tt(=LPAR())var(list)tt(RPAR())' is subject to process substitution. In the case of the tt(<) or tt(>) forms, the shell will run process -var(list) asynchronously, connected to a named pipe (FIFO). -The name of this pipe will become the argument to the command. -If the form with tt(>) -is selected then writing on this file will provide input for var(list). -If tt(<) is used, then the file passed as an argument will -be a named pipe connected to the output of the var(list) process. -For example, +var(list) asynchronously. If the system supports the tt(/dev/fd) +mechanism, the command argument is the name of the device file +corresponding to a file descriptor; otherwise, if the system supports named +pipes (FIFOs), the command argument will be a named pipe. If the form with +tt(>) is selected then writing on this special file will provide input for +var(list). If tt(<) is used, then the file passed as an argument will +be connected to the output of the var(list) process. For example, nofill(tt(paste LPAR())var(process1)tt(RPAR() >LPAR())var(process2)tt(RPAR() >/dev/null)) @@ -292,9 +292,19 @@ cuts fields 1 and 3 from the files var(file1) and var(file2) respectively, pastes the results together, and sends it to the processes var(process1) and var(process2). -Note that the file, which is passed as an argument to the command, -is a system pipe, so programs that expect to lseek (see manref(lseek)(2)) -on the file will not work. + +Both the tt(/dev/fd) and the named pipe implementation have drawbacks. In +the former case, some programmes may automatically close the file +descriptor in question before examining the file on the command line, +particularly if this is necessary for security reasons such as when the +programme is running setuid. In the second case, the file passed as an +argument to the command is a system pipe, so programs that expect to lseek +(see manref(lseek)(2)) on the file will not work; furthermore, if the +programme does not actually open the file the subshell attempting to read +from or write to the pipe will (in a typical implementation, different +operating systems may have different behaviour) block for ever and have to +be killed explicitly. + Also note that the previous example can be more compactly and efficiently written (provided the tt(MULTIOS) option is set) as: -- Peter Stephenson Cambridge Silicon Radio, Unit 300, Science Park, Milton Road, Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070