Komenda nodejs exec kończy się niepowodzeniem bez użytecznego komunikatu o błędzie
To jest kod do wykonania
cp.exec("cc -Wall /tmp/test.c -o /tmp/test", function(e, stdout, stderr) {
if (e) {
var errorstr = "Compilation failed with the following error<br>"+ e.message.toString()
client.send(errorstr)
console.log(e, stdout, stderr)
ee.prototype.removeAllListeners()
} else if (stderr.length > 0) {
client.send("Compilion finished with warnings\n"+ stderr + '\n')
client.send('compiled')
ee.prototype.emit('compiled')
} else {
client.send("Compilation successful")
ee.prototype.emit('compiled')
}
})
„klient” jest argumentem argumentu wywołania zwrotnego socket.io. „ee” jest instancją EventEmitter
Wracając do problemu. Po uruchomieniu kodu wywołanie zwrotne mówi, że polecenie nie powiodło się. console.log (e, stdout, stderr) to
{ [Error: Command failed: ] killed: false, code: false, signal: undefined } '' ''
/tmp/test.c to poprawny kod C i po sprawdzeniu katalogu / tmp uważam, że test.c jest poprawny, a binarny „test”jest jest generowany i działa w powłoce, jest poprawnie wykonany. Więc nie rozumiem, dlaczego sygnalizuje nieudane wykonanie. Informacje o obiekcie błędu również nie są pomocne. Będzie wdzięczny za jakąś pomoc / wyjaśnienie