0

我知道这个概念听起来有点滥用(?),但仍然 - 我如何在 bash 中创建一个管道:

  1. 没有能力
  2. 因此不需要内存副本,并且
  3. 要求写被阻塞
4

1 回答 1

1

我在这里猜了很多。但可能您正在考虑协同处理,但不知道该术语的含义。

bash 支持协同进程: http://www.gnu.org/software/bash/manual/html_node/Coprocesses.html

    The format for a coprocess is:

    coproc [NAME] command [redirections]

    This creates a coprocess named NAME. 
If NAME is not supplied, the default name is COPROC.

NAME must not be supplied if command is a simple command (see Simple Commands); 

otherwise, it is interpreted as the first word of the simple command.

执行 coproc 时,shell 在执行 shell 的上下文中创建一个名为 NAME 的数组变量(请参阅数组)。command 的标准输出通过管道连接到执行 shell 中的文件描述符,并将该文件描述符分配给 NAME[0]。

command 的标准输入通过管道连接到执行 shell 中的文件描述符,并将该文件描述符分配给 NAME[1]。

此管道在命令指定的任何重定向之前建立(请参阅重定向)。

文件描述符可以用作 shell 命令的参数和使用标准词扩展的重定向。

于 2013-02-24T00:15:02.063 回答