zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-users@sunsite.dk
Cc: dominik.vogt@gmx.de
Subject: Re: why does "jobs | wc" not work?
Date: Tue, 26 Nov 2002 12:08:16 +0000	[thread overview]
Message-ID: <14578.1038312496@csr.com> (raw)
In-Reply-To: "Dominik Vogt"'s message of "Tue, 26 Nov 2002 12:42:22 +0100." <20021126114222.GG1937@gmx.de>

Dominik Vogt wrote:
> > In zsh
> > 
> > jobs | anything
> > 
> > causes the shell to fork for the left hand side of the pipeline.
> 
> Um, why must builtin commands run in a subshell?  I would have
> naively thought commands like "echo something | ..." would just
> run in the current shell.  Spawning a subshell sounds a bit
> inefficient.

That's how all pipes work in all shells and scripting languages in all
variants of UNIX:  one process feeds its output to another process, so
one side of the pipe has to be forked as a separate process.  The only
question is which bits are forked off.

The only obvious alternative is the horrible method which used to be
used in MSDOS: fake separate processes by switching between the two
tasks; but we are certainly never going to have a task manager in the
shell when we have a proper multiprocessor operating system to do the
job more efficiently.

> > In 4.1, we use the obvious workaround:  remember that we're in a subshell
> > of an interactive shell and keep a fossilized list of the jobs.
> 
> Obvious, maybe, but it still sounds wrong in my ears.

Just in case my explanation above hasn't made this remark obvious:
wrong in what way?  It's either that or no output at all.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************



  parent reply	other threads:[~2002-11-26 12:09 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-26 10:49 Dominik Vogt
2002-11-26 10:56 ` Vincent Lefevre
2002-11-26 11:09 ` Peter Stephenson
2002-11-26 11:17   ` Vincent Lefevre
2002-11-26 11:27     ` Peter Stephenson
2002-11-26 11:42   ` Dominik Vogt
2002-11-26 11:59     ` Vincent Lefevre
2002-11-26 12:08     ` Peter Stephenson [this message]
2002-11-26 12:48       ` Dominik Vogt
2002-11-26 13:05         ` Peter Stephenson
2002-11-26 13:33           ` Dominik Vogt
2002-11-26 17:20             ` Danek Duvall
2002-11-26 13:13         ` Vincent Lefevre
2002-11-26 11:24 ` Stephane Chazelas
2002-11-26 17:11 Borzenkov Andrey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=14578.1038312496@csr.com \
    --to=pws@csr.com \
    --cc=dominik.vogt@gmx.de \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).