I have a small utility - a Windows executable written in C++ that returns either 0 or 1 as its exit code. I can run this C++ executable from Node js and pass command line arguments there. Is there any way I can read the exit code of the command line app in Node js?
Asked
Active
Viewed 350 times
1 Answers
1
Yes, you get it as a parameter for the close event. To cite the example code from the documentation:
const { spawn } = require('child_process');
const ls = spawn('ls', ['-lh', '/usr']);
ls.on('close', (code) => {
console.log(`child process exited with code ${code}`);
});

dabadab
- 388
- 1
- 10