From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4417 invoked from network); 23 Oct 2003 03:12:52 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 23 Oct 2003 03:12:52 -0000 Received: (qmail 27868 invoked by alias); 23 Oct 2003 03:12:45 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 19200 Received: (qmail 27859 invoked from network); 23 Oct 2003 03:12:44 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 23 Oct 2003 03:12:44 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [4.3.58.249] by sunsite.dk (MessageWall 1.0.8) with SMTP; 23 Oct 2003 3:12:44 -0000 Received: (from schaefer@localhost) by candle.brasslantern.com (8.11.6/8.11.6) id h9N3CgF05859 for zsh-workers@sunsite.dk; Wed, 22 Oct 2003 20:12:42 -0700 From: Bart Schaefer Message-Id: <1031023031242.ZM5858@candle.brasslantern.com> Date: Thu, 23 Oct 2003 03:12:42 +0000 In-Reply-To: <20031022224654.C3B4DDF259@swordfish.cs.caltech.edu> Comments: In reply to Troy Bridoux "zsh 4.0.2 bug: jobs pipes no output" (Oct 22, 3:46pm) References: <20031022224654.C3B4DDF259@swordfish.cs.caltech.edu> X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-workers@sunsite.dk Subject: Re: zsh 4.0.2 bug: jobs pipes no output MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Oct 22, 3:46pm, Troy Bridoux wrote: } Subject: zsh 4.0.2 bug: jobs pipes no output Minor point, but 4.0.2 is two years (five revisions) out of date. } As you can see, "jobs"s standard output gives nothing to "cat" This is intentional behavior, not a bug. However, it's been a point of confusion for long enough that it was "fixed" about 15 months ago in development versions of zsh (4.1.x). It's intentional in that zsh forks off the left side of pipelines and tries to keep the right side in the current shell, whereas nearly all other shells either always fork both sides of a pipeline, or fork the right side. Without going into the reasons why forking left first is preferable, this means that when a builtin is on the left, it is run in a subshell -- and subshells do not have job control, and therefore have no jobs to list. The "fix" for this was to allow the subshell to retain part of the job table information from the parent, and print it out -- but it means there can be race conditions, so that the output from "jobs" on the left side of a pipe may be incorrect with respect to the actual list of jobs being managed by the parent. For example: zagzig% echo $ZSH_VERSION 4.1.1-dev-1 zagzig% sleep 20 & [1] 5850 zagzig% (sleep 30; jobs) | cat [1] + done sleep 20 [1] + running sleep 20 zagzig% Whether it's better to have the job list be incorrect or unavailable remains a matter of philosophical debate. I'm beginning to think I prefer "unavailable."