From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2089 invoked from network); 10 Jan 2005 17:11:08 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 10 Jan 2005 17:11:08 -0000 Received: (qmail 57306 invoked from network); 10 Jan 2005 17:11:02 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 10 Jan 2005 17:11:02 -0000 Received: (qmail 15860 invoked by alias); 10 Jan 2005 17:10:47 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 20664 Received: (qmail 15844 invoked from network); 10 Jan 2005 17:10:47 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 10 Jan 2005 17:10:47 -0000 Received: (qmail 54839 invoked from network); 10 Jan 2005 17:09:47 -0000 Received: from smtp-out3.blueyonder.co.uk (195.188.213.6) by a.mx.sunsite.dk with SMTP; 10 Jan 2005 17:09:44 -0000 Received: from sc ([82.41.210.43]) by smtp-out3.blueyonder.co.uk with Microsoft SMTPSVC(5.0.2195.6713); Mon, 10 Jan 2005 17:10:16 +0000 Date: Mon, 10 Jan 2005 17:11:01 +0000 From: Stephane Chazelas To: Zsh hackers list Subject: Re: multios and unnecessary processes Message-ID: <20050110171101.GD4432@sc> Mail-Followup-To: Zsh hackers list References: <20050109164753.GA4246@sc> <1050109203218.ZM22780@candle.brasslantern.com> <20050110094918.GA4432@sc> <1050110165325.ZM26928@candle.brasslantern.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1050110165325.ZM26928@candle.brasslantern.com> User-Agent: Mutt/1.5.6i X-OriginalArrivalTime: 10 Jan 2005 17:10:16.0634 (UTC) FILETIME=[417009A0:01C4F737] X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: * X-Spam-Status: No, hits=1.5 required=6.0 tests=RCVD_IN_SORBS autolearn=no version=2.63 X-Spam-Hits: 1.5 On Mon, Jan 10, 2005 at 04:53:25PM +0000, Bart Schaefer wrote: [...] > } ~$ zsh -o nomultios -c '{ lsof -ag $$ -d 0-2,10-15 2>&1 >&3 3>&- | tr a b 3>&-; } 3>&1' > > If the number of processes spawned is important, you have to know when > to use curly braces and when to force a subshell with parens. Curly > braces imply that the parent zsh sticks around and waits, whereas a > subshell with parens can simply do an exec. > > zsh -fc '{ ( lsof -ag $$ -d 0-2,10-15 2>&1 >&3 3>&-; ) | tr a b 3>&-; } 3>&1' > > COMMAND PID PGRP USER FD TYPE DEVICE SIZE NODE NAME > tr 26811 26811 schaefer 0r FIFO 0,0 72995 pipe > tr 26811 26811 schaefer 1u CHR 136,7 9 /dev/pts/7 > tr 26811 26811 schaefer 2u CHR 136,7 9 /dev/pts/7 > lsof 26822 26811 schaefer 0u CHR 136,7 9 /dev/pts/7 > lsof 26822 26811 schaefer 1u CHR 136,7 9 /dev/pts/7 > lsof 26822 26811 schaefer 2w FIFO 0,0 72995 pipe That makes sense but is not very intuitive given that (...) is generally thought as the form spawning additional processes. However to get back to my initial statement, don't you agree it's a problem that cmd >&2 >&- >&2 doesn't redirect stdout to stderr but to a pipe to a background process that just echos the output to stderr? That's not too big an issue. I was just trying to give some code example in comp.unix.shell that would work the same for any shell (including zsh with multios). -- Stéphane