Tag: mkfifo

为什么在节点块child_process.exec中打开一个fifopipe道?

当我在bash中运行这个: mkfifo im-a-pipe && node -e ' var fs = require("fs") var childProcess = require("child_process") console.log("pre-open") fs.open("im-a-pipe", "w", function(err, fd){ if(err) throw err console.log("opened") }) console.log("post-open") childProcess.exec("echo wat") console.log("YOU CAN NOT SEE MEEE") ' 我期望以下输出: pre-open post-open YOU CAN NOT SEE MEEE 但是,在打印前两行之后,节点等待: pre-open post-open 我在想,这可能与pipe道阻塞有关,直到有东西打开对方,但这种行为让我感到惊讶。 我是否错过了这些function应该如何运作?