help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Waiting for a sub-process to finish


From: Chet Ramey
Subject: Re: [Help-bash] Waiting for a sub-process to finish
Date: Wed, 7 Jun 2017 08:15:52 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.1.1

On 6/1/17 2:11 PM, João Eiras wrote:
> Talking generically about process substitution
> 
>   command <(generate_input) > >(collect_output)
>   second_co
> 
> Looking at that code I would always expect the three tasks to be
> completed before "second_command" executed, since there is no
> ampersand (&) being used anywhere. Else, every single time there is
> some process substitution, one would be forced to use job control plus
> "wait", which does not make that much sense as "jobs" yields nothing
> and $! only returns the last process.
> 
> So, every single instruction that adds a substituted process, should
> be followed by an implicit "wait address@hidden". At the very
> least I'd like see such behavior being a shell option
> (https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html)
> Or, at least "jobs" should be populated accordingly and "wait" work as
> such, which is what bash 4.4 does I presume.

Bash-4.4 allows `wait' to wait for the last process substitution, since it
has always set $!. It was an oversight that it wasn't possible before that.
Bash-4.3 and earlier tried to verify that `wait' was waiting for a child
of the shell instead of letting waitpid return an error.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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