bug-bash
[Top][All Lists]
Advanced

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

Re: 'wait' in command group in pipeline fails to recognize child process


From: Dale R. Worley
Subject: Re: 'wait' in command group in pipeline fails to recognize child process
Date: Tue, 22 Jun 2021 20:35:15 -0400

> It's not the brace command; it's the pipeline.
>
>> Minimal repro:
>> 
>>    $ sleep 1 & { wait $!; } | cat
>>    [1] 665454
>>    bash: wait: pid 665454 is not a child of this shell

Interestingly, this is almost trivial to clairfy:

    $ sleep 5 & { wait $!; }
    [1] 19069
    [1]+  Done                    sleep 5
    $

> I was also misled by the term "subshell" which is not a proper shell 
> like a subprocess is just another process.

The criticial point is that "being a subshell" is a relationship between
the child bash process and its parent.  Intuitively, a subshell is
created whenever a bash child process is created "implicitly".  The
manual page et al. enumerate all the ways a subshell can be created;
search for the word "subshell".

Dale



reply via email to

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