私はchild_process
モジュールとラズベリーパイのmpg123プレーヤーを使ってnode.jsにmp3ウェブラジオを作りようとしています。Node.js子プロセスに書き込む
ここで問題です: 私はストリームに書き込みしようとすると、私は常にエラーを取得:
Error: write EPIPE
at exports._errnoException (util.js:1026:11)
at WriteWrap.afterWrite (net.js:795:14)
ここで私はそれをテストしようとしたものです:
//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()
誰もが知っている、どのようなすべての操作が完了するまで、作成された書き込みストリームは閉じられませんか?
そしてもちろん、私はまだこれをグーグルで検索:
Child_process throw an Error: write 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
助けてください!
'ls/home/pi/music'の子プロセスは出力に何か書き込む前に終了しませんか? – dpetrini
私はプロセス**が終了すると思います**これがエラーの原因です。しかし、私はこれを止める方法を知らない:c。 もしそれが止まらないなら、私はエラーを生成しないと思います... –
もう片方の側で既に終了している間に、あなたが '.end()' stindストリームを持っているからですか? – n00dl3