help-bash
[Top][All Lists]
Advanced

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

Re: Multiple concurrent coprocesses


From: Zachary Santer
Subject: Re: Multiple concurrent coprocesses
Date: Thu, 8 Apr 2021 21:52:43 -0400

In my code, both coprocesses have a while loop reading from the input
pipe, so when the writing coproc file descriptor in the main process
is closed, the while loop and the coproc it's in both end.

Where the coproc-named array variable in the main process is unset as
soon as the coproc ends, I'm kind of afraid to close its reading file
descriptor after I close the writing file descriptor. If Bash closes
the reading file descriptor behind the scenes, as soon as the coproc
ends, this could present a race condition. Does Bash do this, or would
the reading file descriptor always still be open, even after the
coproc has ended and its array variable has disappeared?

Expanding on what I said earlier, you could even make no attempt to
keep the coproc file descriptors out of any subshells. If the Bash
programmer needs to keep them out, he or she has the tools to do so. I
understand the implication for backwards-compatibility, though.

Zack



reply via email to

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