zsh-workers
 help / color / mirror / code / Atom feed
* [QUESTION] Inheritance of file descriptors in <( ... ) construct
@ 2018-05-26  0:01 dana
  2018-05-26 17:52 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: dana @ 2018-05-26  0:01 UTC (permalink / raw)
  To: Zsh workers

Hello,

I'm wondering about the following behaviour:

  % ( fd=; exec {fd}>&2; : $( print foo >&$fd ) )
  foo
  % ( fd=; exec {fd}>&2; : =( print foo >&$fd ) )
  foo
  % ( fd=; exec {fd}>&2; : <( print foo >&$fd ) )
  zsh: 12: bad file descriptor

As you can see, $fd (12) was inherited by the $( ... ) and =( ... ) constructs,
but not by the <( ... ) one.

Everything works as expected with FDs < 10, though:

  % ( fd=9; exec 9>&2; : $( print foo >&$fd ) )
  foo
  % ( fd=9; exec 9>&2; : =( print foo >&$fd ) )
  foo
  % ( fd=9; exec 9>&2; : <( print foo >&$fd ) )
  foo

Is this intended and/or desirable? Maybe something to do with the fact that
<( ... ) is itself exposed as a >=10 file descriptor? But it seems smart enough
not to re-use the number that $fd had (it uses 13 in this example), so...?

Cheers

dana


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

* Re: [QUESTION] Inheritance of file descriptors in <( ... ) construct
  2018-05-26  0:01 [QUESTION] Inheritance of file descriptors in <( ... ) construct dana
@ 2018-05-26 17:52 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2018-05-26 17:52 UTC (permalink / raw)
  To: dana; +Cc: Zsh workers

On Fri, May 25, 2018 at 5:01 PM, dana <dana@dana.is> wrote:
>
> I'm wondering about the following behaviour:
>
>   % ( fd=; exec {fd}>&2; : $( print foo >&$fd ) )
>   foo
>   % ( fd=; exec {fd}>&2; : =( print foo >&$fd ) )
>   foo
>   % ( fd=; exec {fd}>&2; : <( print foo >&$fd ) )
>   zsh: 12: bad file descriptor

This looks similar to the thread around workers/42708 ... except that
instead of not closing the descriptor created by <(...) we also need
to not close FDT_EXTERNAL descriptors when spawning <(...).

There doesn't seem to be any straightforward way to do this with the
current implementation of closem().


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

end of thread, other threads:[~2018-05-26 17:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-26  0:01 [QUESTION] Inheritance of file descriptors in <( ... ) construct dana
2018-05-26 17:52 ` 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).