Hi,
I want to read from a file and want to timeout if there is no data. How can
I cancel the fs.read, closing the file-descriptor doesn't work. Is it a bug?
Here is a example:
You have to create a fifo: "mkfifo file"
var fs=require('fs');
fs.open('file', 'r+', function(err,fd) {
console.log("start reading on "+fd);
var length=5;
var data = new Buffer(length);
data.fill("-");
setTimeout(function(){
console.log("close fd "+fd);
fs.close(fd,function(err) {
console.log("close done: "+err);
});
}, 5000);
fs.read(fd, data, 0, length,undefined, function(error, got) {
console.log("error: "+error);
console.log("data : "+data);
});
});
After the timeout of 5 seconds, the file-descriptor is closed, but the read
still can get data if you make "echo hello > file".
How to stop the fs.read? How to kick it from the listening queue?
Thanks
Oliver Joa
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.