coproc <命令> 与 <命令> & 相同吗?

Tra*_*iet 5 bash coprocesses

我读过的内容$coproc < command >不同于$< command > &与在子 shell 进程中coproc执行的command

但当我测试它时,它的工作原理就像$< command > &. 测试如下:

第一:测试行为$< command > &

  1. 跑步$nano &在tty1
  2. 在另一个 tty 上,输出来自$ps -t tty1 --forest表明 nano 进程是 -bash 进程的子进程(登录 bash shell 进程 -> 未创建子 shell 进程)

第二:测试行为$coproc < command >

  1. 跑步$coproc nano在tty1
  2. 在另一个 tty 上,输出来自$ps -t tty1 --forest上面相同(没有创建子 shell 进程)

也是如此$coproc < command >和一样吗$< command > &

使用的 shell 是bash shell

Rud*_*diC 2

区别在于创建了两个 I/O 通道,如下所述man bash

协进程在子 shell 中异步执行,就像使用 & 控制运算符终止命令一样,并在执行 shell 和协进程之间建立双向管道。