So, I have a simple app (I have written) which writes to stdout.
When I run it by itself, the output is being printed fine.
Now, when I spawn the process with node... nothing happens (apart from a message saying the process has finished)
Here's my code:
var spawn = require('child_process').spawn;
helper = spawn("myApp", []);
helper.stdout.on('data', function(data) {
console.log("GOT: " + data);
});
helper.stdout.on('end', function(data) {
console.log("FINISHED: " + data);
});
helper.on('exit', function(code) {
console.log("CLOSED!");
});
And here's the output:
FINISHED: undefined
CLOSED!
Yep, just that.
What's going on? Am I missing something?
spawn()tospawn("sh", ["-c", "echo hello world"])it works fine for me, though I get the "close" event before the data.endeven does fire. Thestdout.on('data',...)part isn't...fprintfing tostdout... Let me double-check.