node.js中的额外stdiostream是否被child_process.spawn阻塞?

当使用spawn()创buildsubprocess时,您可以通过options.stdioparameter passing选项来创build多个stream。 在标准3(stdin,stdout,stderr)之后,你可以传递额外的stream和pipe道,这将是subprocess中的文件描述符。 然后你可以使用fs.createRead / WriteStream来访问这些。

请参阅http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options

 var opts = { stdio: [process.stdin, process.stdout, process.stderr, 'pipe'] }; var child = child_process.spawn('node', ['./child.js'], opts); 

但是这些文件并不清楚这些pipe道堵塞的位置。 我知道标准input/标准输出/标准错误阻塞,但'pipe'呢?

一方面他们说:

“请注意,父级和子级上的send()方法是同步的 – 不build议发送大块数据(可以使用pipe道,请参见child_process.spawn”

但在别处他们说:

process.stderr和process.stdout不同于Node中的其他stream,写入它们通常是阻塞的。

 They are blocking in the case that they refer to regular files or TTY file descriptors. In the case they refer to pipes: They are blocking in Linux/Unix. They are non-blocking like other streams in Windows. 

有人可以澄清这一点吗? pipe道阻塞在Linux上?

我需要传输大量的数据而不会阻塞我的工作进程。

有关:

  • 如何在Node.js中以非阻塞方式将大量的数据从subprocess发送到父进程?
  • 如何在不使用阻塞stdio的情况下将大数据从/传输到node.js中的subprocess?