If I run my Electron exe within Command Prompt, the app is run, but when the window is closed control is not passed back to Command Prompt.
I have to Ctrl+C and then I get control back.
To intercept the closing of the window I do:
app.on('window-all-closed', () => {
log.debug('window-all-closed' + os.EOL);
expectKill=true;
if (serverProcess) {
log.debug('Killing ' + serverProcess.pid + os.EOL);
const kill = require('tree-kill');
kill(serverProcess.pid, 'SIGTERM', function () {
serverProcess = null;
});
}
if (process.platform !== 'darwin') {
log.debug('app.quit()' + os.EOL);
app.quit();
}
return;
})
serverProcess is a spawned process. I can see this is correctly killed.
In the logs I can see:
app.quit()
All of the processes created by the Electron app, including the serverProcess mentioned above and the Electron exe itself disappear from Task Manager.
However, control never comes back:
C:\Program Files\electron-app\bin>electron-app.exe
C:\Program Files\electron-app\bin>
19:15:06.566 > window-all-closed
19:15:06.575 > Killing 3144
19:15:06.589 > app.quit()
Sometimes, if I then restart the app, I get an odd hang:
C:\Program Files\electron-app\bin>electron-app.exe
C:\Program Files\electron-app\bin>
... the app is hung at this point and I have to Ctrl+C to get it back to cmd.exe control.
Why isn't control given back to cmd.exe after app.quit() has been called?