Bash coprocesses
mouse 45 · person cloud · link
Last update
2019-07-25
2019
07-25
«control async process stdin/stdout simultaneously»

A coprocess is executed asynchronously in a subshell with a two-way pipe established between the executing shell and the coprocess.

Esample: redirect netcat stdout ${COPROC[0]} to bash stdin, and bash stdout to netcat stdin ${COPROC[1]}

1
2
coproc netcat -l -p 1234
exec bash <&${COPROC[0]} >&${COPROC[1]} 2>&1

Source: stackexchange, gnu.org