zsh-workers
 help / color / mirror / code / Atom feed
* zsh 4.0.2 bug: jobs pipes no output
@ 2003-10-22 22:46 Troy Bridoux
  2003-10-23  3:12 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Troy Bridoux @ 2003-10-22 22:46 UTC (permalink / raw)
  To: zsh-workers

Debian Linux 3.0

% jobs
[1]  + suspended  vim

% jobs | cat


As you can see, "jobs"s standard output gives nothing to "cat"


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: zsh 4.0.2 bug: jobs pipes no output
  2003-10-22 22:46 zsh 4.0.2 bug: jobs pipes no output Troy Bridoux
@ 2003-10-23  3:12 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2003-10-23  3:12 UTC (permalink / raw)
  To: zsh-workers

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."


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-10-23  3:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-22 22:46 zsh 4.0.2 bug: jobs pipes no output Troy Bridoux
2003-10-23  3:12 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).