diff --git a/arduino-ide-extension/src/node/arduino-daemon-impl.ts b/arduino-ide-extension/src/node/arduino-daemon-impl.ts index d2fe7d81b..16db90631 100644 --- a/arduino-ide-extension/src/node/arduino-daemon-impl.ts +++ b/arduino-ide-extension/src/node/arduino-daemon-impl.ts @@ -10,7 +10,6 @@ import { } from '@theia/core/lib/common/disposable'; import { Event, Emitter } from '@theia/core/lib/common/event'; import { deepClone } from '@theia/core/lib/common/objects'; -import { environment } from '@theia/application-package/lib/environment'; import { EnvVariablesServer } from '@theia/core/lib/common/env-variables'; import { BackendApplicationContribution } from '@theia/core/lib/node/backend-application'; import { ArduinoDaemon, NotificationServiceServer } from '../common/protocol'; @@ -71,22 +70,6 @@ export class ArduinoDaemonImpl const cliPath = this.getExecPath(); this.onData(`Starting daemon from ${cliPath}...`); const { daemon, port } = await this.spawnDaemonProcess(); - // Watchdog process for terminating the daemon process when the backend app terminates. - spawn( - process.execPath, - [ - join(__dirname, 'daemon-watcher.js'), - String(process.pid), - String(daemon.pid), - ], - { - env: environment.electron.runAsNodeEnv(), - detached: true, - stdio: 'ignore', - windowsHide: true, - } - ).unref(); - this.toDispose.pushAll([ Disposable.create(() => { if (daemon.pid) { @@ -173,10 +156,9 @@ export class ArduinoDaemonImpl const cliPath = this.getExecPath(); const ready = new Deferred<{ daemon: ChildProcess; port: string }>(); const options = { - shell: true, env: { ...deepClone(process.env), NO_COLOR: String(true) }, }; - const daemon = spawn(`"${cliPath}"`, args, options); + const daemon = spawn(cliPath, args, options); // If the process exists right after the daemon gRPC server has started (due to an invalid port, unknown address, TCP port in use, etc.) // we have no idea about the root cause unless we sniff into the first data package and dispatch the logic on that. Note, we get a exit code 1. diff --git a/arduino-ide-extension/src/node/daemon-watcher.ts b/arduino-ide-extension/src/node/daemon-watcher.ts deleted file mode 100644 index 842a4e2f2..000000000 --- a/arduino-ide-extension/src/node/daemon-watcher.ts +++ /dev/null @@ -1,22 +0,0 @@ -import psTree from 'ps-tree'; -import kill from '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) { - const parsedPid = Number.parseInt(PID, 10); - if (!Number.isNaN(parsedPid)) { - kill(parsedPid); - } - } - kill(daemonPid, () => process.exit()); - }); - } -}, 1000);