bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Command hangs when using process substitution


From: Robert Elz
Subject: Re: Command hangs when using process substitution
Date: Sun, 19 Nov 2023 08:29:58 +0700

    Date:        Sun, 19 Nov 2023 07:40:00 +1000
    From:        Martin D Kealey <martin@kurahaupo.gen.nz>
    Message-ID:  
<CAN_U6MUEBHJyCWvuBS3Zd7dD=V2ENSqERa8Z9T-d4RuzWh-Ncg@mail.gmail.com>

  | The fact that you don't *want* the output of xclip connected to tr
  | (because it makes tr wait for xclip *and all its children* to finish,
  | while the shell waits for tr to finish) does not make zsh "correct".

It all depends upon the definition of what is supposed to happen
to the stdout of a process created as a process substitution
which is to read from its stdin (as in the example in question)
or what it should do with its stdin if intended to write output
through the named pipe or whatever.

Since process substitution is not a standardised feature, every
shell is able to decide for itself, and others are free to
express opinions about which they feel is better (more useful).
"Correct" is not the appropriate term to use.

Personally, just as a background process created in a non
job control context gets its stdin altered to /dev/null
(it shouldn't read from there, but just in case it does)
I'd think it generally better to redirect the unused
stdin or stdout (whichever is not connected to the invoking
process via the fifo, or whatever) be similarly redirected
to /dev/null, so output it should not be producing doesn't
corrupt the real output, and other processes aren't, like
here, left hanging waiting for potential output from that
process that is never going to come.

In the unusual case where this default redirect isn't wanted,
an explicit redirect can always be used to override it.

kre



reply via email to

[Prev in Thread] Current Thread [Next in Thread]