Node.js写入subprocess

我正在使用child_process模块和覆盆子pi上的mpg123播放器在node.js中制作mp3 webradio。

下面是问题:当我尝试写入一个stream,我总是得到一个错误:

 Error: write EPIPE at exports._errnoException (util.js:1026:11) at WriteWrap.afterWrite (net.js:795:14) 

这是我试图testing它:

 //create a subprocess var test = childProcess.exec('ls /home/pi/music'); //pipe all the output to the process output test.stdout.pipe(process.stdout); test.stderr.pipe(process.stderr); test.stdin.setEncoding('utf-8'); //here I just want to write a key to the subprocess test.stdin.write('q'); test.stdin.end() 

任何人都知道,做什么,创build的写入stream将不会被closures,直到一切都完成了?

当然,我仍然在谷歌search这个:

Child_process抛出一个错误:写入EPIPE

https://github.com/nodejs/node/issues/2985

https://nodejs.org/api/child_process.html#child_process_subprocess_stdin

https://nodejs.org/api/stream.html#stream_writable_write_chunk_encoding_callback

请帮忙!