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: Greg Wooledge
Subject: Re: 'wait' in command group in pipeline fails to recognize child process
Date: Tue, 22 Jun 2021 07:31:38 -0400

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



reply via email to

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