help-bash
[Top][All Lists]
Advanced

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

Re: Coproc within coproc supported?


From: Tadeus Prastowo
Subject: Re: Coproc within coproc supported?
Date: Fri, 18 Nov 2022 11:33:54 +0100

Hi!

On Fri, Nov 18, 2022 at 12:11 AM Chet Ramey <chet.ramey@case.edu> wrote:
>
> On 11/17/22 5:43 AM, Tadeus Prastowo wrote:

[...]

> >>> Is it true that the intention of the statement in the man page is that
> >>> at most one coprocess exists for every concurrently running Bash
> >>> process where $$ expands to the same PID?
> >>
> >> No. Coprocs are process-based.
> >
> > In that case, why does Bash 4.3.48 when executing the following lines
> > issues the coproc-exists warning despite the fact that if I understand
> > it correctly, the (...)-construct creates a new process?
> >
> > coproc sleep 1
> > echo $$, $BASHPID, $COPROC_PID >&2
> > (coproc sleep 1; echo $$, $BASHPID, $COPROC_PID >&2; wait)
> > wait
>
> A (subshell) is an exact copy of the parent shell, so it inherits the
> coproc. It just won't be able to write or read to the coproc, and can't
> wait for a coproc it inherits, since the subshell is not the coproc
> process's parent.

Given that coprocs are process-based and a subshell is a new process
despite being an exact copy of the parent process, I think logically
it follows that it is not a bug if the subshell creates a coproc.
Therefore, Bash back in the version 4.3.48 should have not issued the
coproc-exists warning.

Is my reasoning correct?

Thank you.

-- 
Best regards,
Eus



reply via email to

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