I have this code:
Printer.prototype.watch = function() {
var self = this; var args = ["-P", this.name];
var lpq = spawn('lpq', args);
lpq.stdout.on("data", function(data) {
(some irrelevant code)
});
lpq.on("exit", function() {
self.watch();
});
};
After some recursive calls, spawn('lpq', args)
returns a object with stdout=undefined
. Why is this happening?
Try stderr so you can see the error message.
lpq.stderr.on("data", function(data) {
console.log("stderr------",data.toString());
});