nodejs exec command failing with no useful error message #4590
Comments
Sorry, can't reproduce. Your test case doesn't run standalone but when I modify it like this: var cp = require('child_process');
cp.exec("cc -Wall /tmp/test.c -o /tmp/test", function(e, stdout, stderr) {
console.log(stdout);
console.log(stderr);
if (e) throw e;
}); Then it produces the following output:
|
What is |
Well, that was a mistake, yes. But correcting that didn't affect the results |
I just had the same issue (assuming this is just about the weird error message that is Windows 7 64 bit, Node 0.10.29. Initially with a CLR executeable, but also reproduceable with node itself
|
having same problem var cmd="gcc a.c -o code"; and c code and out put |
Same as well, even with a simple exec('diff '+fname+' '+compname, function(error, stdout) {
if(error) {
console.log(error);
callback(error);
return;
}
console.log("difference: "+stdout);
callback(stdout);
}); and error message:
The files definitely exist. Command works fine from terminal. EDIT: In short, this code is reporting false errors. |
This is the code to execute
'client' is the argument of socket.io's callback argument. 'ee' is an instance of EventEmitter
Coming to the problem. On running the code, the callback says that the command was unsuccessful. console.log(e, stdout, stderr) is
{ [Error: Command failed: ] killed: false, code: false, signal: undefined } '' ''
/tmp/test.c is a valid C code and on checking the directory /tmp , I find that test.c is proper and the binary 'test' is being generated and on running in a shell, is properly executed (echo $? of the same command in the shell returns 0). So I dont understand why it is flagging unsuccessful execution. The error object's information is unhelpful too.
But the most disturbing thing about this is e.code, whose value is 'false', something that should be an 8-bit integer, not boolean. I have checked this example with the branches 'v0.9.6-pre' and 'v0.8.17-release'
(This issue was discussed in StackOverFlow )
The text was updated successfully, but these errors were encountered: