node.js - Close readable stream to FIFO in NodeJS -
i creating readable stream linux fifo in nodejs this:
var stream = fs.createreadstream('fifo');
this works , can receive data fifo fine. problem want have method shut software down gently , therefore need close stream somehow.
calling
process.exit();
does have no effect stream blocking.
i tried destroy stream manually calling undocumented methods stream.close()
stream.destroy()
described in answers of question.
i know kill own process using process.kill(process.pid, 'sigkill')
feels bad hack , have bad impacts on filesystem or database.
isn't there better way achieve this?
you can try minimal example reproduce problem:
var fs = require('fs'); console.log("creating readable stream on fifo ..."); var stream = fs.createreadstream('fifo'); stream.once('close', function() { console.log("the close event emitted."); }); stream.close(); stream.destroy(); process.exit();
after creating fifo called 'fifo' using mkfifo fifo
.
how modify above code shutdown software correctly?
Comments
Post a Comment