help-bash
[Top][All Lists]
Advanced

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

Re: Coproc within coproc supported?


From: Chet Ramey
Subject: Re: Coproc within coproc supported?
Date: Thu, 17 Nov 2022 18:11:27 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.4.2

On 11/17/22 5:43 AM, Tadeus Prastowo wrote:

It is, and so I would like thank you very much for keeping Bash in a
good shape for so many years.  I really appreciate it.  Despite using
Bash since 2005 when I knew the GNU project for the very first time, I
have appreciated its high-level programming capabilities only recently
when I have to orchestrate many third-party programs to work in
unison.  I find that Bash is indeed an efficient language when it
comes to a system-wide process management that must be afforded using
only BusyBox and the Linux kernel.

Thanks.

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.

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




reply via email to

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