79602208

Date: 2025-05-01 16:42:09
Score: 1
Natty:
Report link

The easiest way to fix this is to not use the COPROC[0] and COPROC[1[ file descriptor. redirect the coprocs stdin / stdout to anonymous pipes.

{ coproc {  loopedElapsedTimeCalculation 'IS_COP'; } <&$fd0 >&$fd1 2>&$fd2; } {fd0}<><(:) {fd1}<><(:) {fd2}>&2

while read -r -u $fd1; do
...
done

you can then send the coproc stuff by writing to &$fd0 (if needed) and read the output by reading from &$fd1

To make parallel execution really easy and efficient, id suggest checking out my forkrun utility. It uses persistent bash coprocs under the hood. You can even set it up to be a persistent async process that you send commands to and itll run them on demand and then quietly wait for more. e.g., something like

{ coproc fr {
    forkrun -N <&$fd0 >&$fd1 2>&$fd2;
  }
} {fd0}<><(:) {fd1}<><(:) {fd2}>&2

echo "loopedElapsedTimeCalculation 'IS_COP'" >&$fd0
# do stuff while that runs
read -r -u $fd1 output
Reasons:
  • Contains signature (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: jkool702