mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-11-17 22:29:27 +00:00
Fixed the daemon process termination.
From now on, we spawn a detached process that will periodically check whether the parent Theia the process is alive, if no, terminates the daemon. Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
17
arduino-ide-extension/src/node/daemon-watcher.ts
Normal file
17
arduino-ide-extension/src/node/daemon-watcher.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import * as psTree from 'ps-tree';
|
||||
const kill = require('tree-kill');
|
||||
const [theiaPid, daemonPid] = process.argv.slice(2).map(id => Number.parseInt(id, 10));
|
||||
|
||||
setInterval(() => {
|
||||
try {
|
||||
// Throws an exception if the Theia process doesn't exist anymore.
|
||||
process.kill(theiaPid, 0);
|
||||
} catch {
|
||||
psTree(daemonPid, function (_, children) {
|
||||
for (const { PID } of children) {
|
||||
kill(PID);
|
||||
}
|
||||
kill(daemonPid, () => process.exit());
|
||||
});
|
||||
}
|
||||
}, 1000);
|
||||
Reference in New Issue
Block a user