zsh-workers
 help / color / mirror / code / Atom feed
* exec >& >(tee hello)
@ 2013-03-26 19:21 Anthony Heading
  2013-03-28 15:46 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Anthony Heading @ 2013-03-26 19:21 UTC (permalink / raw)
  To: zsh-workers

Hi,
On zsh  (5.0 and 4.2.6 -   rhel5 x64),  this command hangs:
      zsh -c 'exec >& >(tee hello)'
It seems to work OK with bash.
Thanks

Anthony




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

* Re: exec >& >(tee hello)
  2013-03-26 19:21 exec >& >(tee hello) Anthony Heading
@ 2013-03-28 15:46 ` Bart Schaefer
  2013-03-28 21:57   ` Phil Pennock
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2013-03-28 15:46 UTC (permalink / raw)
  To: zsh-workers

On Mar 26,  3:21pm, Anthony Heading wrote:
}
} On zsh  (5.0 and 4.2.6 -   rhel5 x64),  this command hangs:
}       zsh -c 'exec >& >(tee hello)'
} It seems to work OK with bash.

Define "work".

Zsh is waiting for "tee hello" to finish.  It's part of the current
command line, and nothing was put in the background, so the current
command is in the foreground until all parts of it finish.  From a
job management perspective this is the same as

    { exec >& } | tee hello

Perhaps

    exec >& >(tee hello &)

is what you want?

(Older versions of zsh put >(...) entirely in the background rather
than treat them as a component of the command line, but that led to
race conditions and processes still running after the parent shell
exited and various other confusion.)

However, there does seem to be a signal-handling bug with your original
command.  When run in an interactive shell, it probably ought to be
possible to interrupt or suspend the >(...) once zsh gets to the point
of waiting for it, but that doesn't work.

Note that both bash and zsh will exit on a SIGPIPE if the tee is killed.


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

* Re: exec >& >(tee hello)
  2013-03-28 15:46 ` Bart Schaefer
@ 2013-03-28 21:57   ` Phil Pennock
  2013-03-28 22:46     ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Phil Pennock @ 2013-03-28 21:57 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

On 2013-03-28 at 08:46 -0700, Bart Schaefer wrote:
> On Mar 26,  3:21pm, Anthony Heading wrote:
> }
> } On zsh  (5.0 and 4.2.6 -   rhel5 x64),  this command hangs:
> }       zsh -c 'exec >& >(tee hello)'
> } It seems to work OK with bash.
> 
> Define "work".
> 
> Zsh is waiting for "tee hello" to finish.  It's part of the current
> command line, and nothing was put in the background, so the current
> command is in the foreground until all parts of it finish.  From a
> job management perspective this is the same as
> 
>     { exec >& } | tee hello
> 
> Perhaps
> 
>     exec >& >(tee hello &)

Okay, now I'm confused.

See, this works:

  zsh -c 'exec > >(tee hello); echo foo'
  zsh -c 'exec > >(tee hello)'

It's only when you try to use >& to redirect both stdout and stderr that
it fails/hangs.

-Phil


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

* Re: exec >& >(tee hello)
  2013-03-28 21:57   ` Phil Pennock
@ 2013-03-28 22:46     ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2013-03-28 22:46 UTC (permalink / raw)
  To: Bart Schaefer, zsh-workers

[-- Attachment #1: Type: text/plain, Size: 691 bytes --]

On Thu, Mar 28, 2013 at 2:57 PM, Phil Pennock <
zsh-workers+phil.pennock@spodhuis.org> wrote:

> Okay, now I'm confused.
>
> See, this works:
>
>   zsh -c 'exec > >(tee hello); echo foo'
>   zsh -c 'exec > >(tee hello)'
>
> It's only when you try to use >& to redirect both stdout and stderr that
> it fails/hangs.
>

> >(...) is parsed as its own syntactic element that semantically means
/connect to a process on a real pipe/.

>& >(...) is two elements, /join stdout with stderr/ and /connect to a
process on a FIFO/.  It only avoids being a syntax error because >(...) is
replaced by a file name to which >& can redirect.

So you're seeing the difference between pipe and FIFO behavior.

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

end of thread, other threads:[~2013-03-28 22:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-26 19:21 exec >& >(tee hello) Anthony Heading
2013-03-28 15:46 ` Bart Schaefer
2013-03-28 21:57   ` Phil Pennock
2013-03-28 22:46     ` 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).