Introduced with Bash 4.0, the coproc keyword allow allows the user to run a process in the background in an asyncronous subshell. During the execution of the process, a pipe is established between the calling shell and the coprocess. The best results are obtained with programs which can be run in a CLI and can read from stdin and write to stdout, better if with an unbuffered stream. The syntax for coprocess is here:
coproc (NAME) command (redirections)
The bits within parentheses are optional, but if you specify a name, coproc will create a coprocess with the name. If no name is given, it will be defaulted to COPROC; and we must not define any name if the following is a simple command, otherwise it will be treated as the first word of the command. The process ID of the shell executing the coprocess is stored in a variable called NAME_PID:
Let's see an example...