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: Martin Jambon
Subject: Re: 'wait' in command group in pipeline fails to recognize child process
Date: Tue, 22 Jun 2021 13:12:10 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1

On 6/22/21 4:31 AM, Greg Wooledge wrote:
On Tue, Jun 22, 2021 at 02:42:40AM -0700, Martin Jambon wrote:
I ran into something that looks like a bug to me, although I'm not super
familiar curly-brace command groups.

Bash version: latest from GitHub mirror (commit ce23728: Bash-5.1 patch 7)

Minimal repro:

   $ sleep 1 & { wait $!; } | cat
   [1] 665454
   bash: wait: pid 665454 is not a child of this shell

I was expecting a success, just like we get without the pipeline:

A pipeline creates two or more subshells, one for each command in the
pipeline.  Therefore, your wait command is running in a different
process than the one which created the sleep background job.

The curly braces are irrelevant here.

unicorn:~$ sleep 1 & wait "$!"|cat
[1] 1290127
bash: wait: pid 1290127 is not a child of this shell

Thank you! Now I know that a subshell is not a shell, $$ being the process ID of the shell, not of the subshell.



reply via email to

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