R
R
return2013-09-15 15:19:16
Node.js
return, 2013-09-15 15:19:16

Close handle ever?

Hey!
I am writing a small module for parsing, in which I give the opportunity to open a file and slowly parse it lazily.
It turns out that in the constructor I open the file descriptor and in the callback I pass the user the opportunity to do something with it. This something will definitely require an open handle.
Will the node close the open descriptor itself when the script finishes executing? Or do you need to somehow take care of it yourself? What are the accepted practices in this regard?
Sorry if this is a dumb question :[

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mithgol, 2013-09-15
@return

When the node finishes executing, the handle will be closed by the operating system.

T
Timur Shemsedinov, 2013-09-15
@MarcusAurelius

Your node process, in which the parser is running, will not work for a long time? That is, does it start only at the time of parsing or does it have some kind of server (for example, http, tcp, ipc) from which parsing is called periodically? What method are you using to open the file? If you do fs.createReadStream(path, [options]), then in the options you can put { autoClose: true }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question