-
Notifications
You must be signed in to change notification settings - Fork 71
Open
Description
Description
When executing ps command while restarting electron on Linux, Node process id is used to collect child process ids. That results in killing not only electron, but also it's siblings - esbuild.
Minimal reproduction
Use vanilla, typescript.
npm create vite@latest
npm i
npm i -D electron vite-plugin-electron vite-plugin-electron-renderer
Complete steps 2, 3 and 4 from vite-plugin-electron "Quick setup".
Edit electron/main.ts to log process ids:
console.log(`Electron pid: ${process.pid}`);
console.log(`Node pid: ${process.ppid}`);
Run the dev scirpt, use logged Node pid to list child processes (77334 in my example).
ps --ppid 77334
PID TTY TIME CMD
77341 pts/1 00:00:00 esbuild
77352 pts/1 00:00:00 electron
Now edit electron/main.ts to trigger restart.
List node child processes again.
ps --ppid 77334
PID TTY TIME CMD
77706 pts/1 00:00:00 electron
🪓 esbuild killed
After this, electron/main.ts is not rebuilt any more, editing src/main.ts will throw [plugin:vite:esbuild] The service is no longer running.
Fix
pidTree within src/utils.ts needs to pass electron's pid to ps command:
// pass tree.pid instead of tree.ppid
: `ps -o pid --no-headers --ppid ${tree.ppid}` // Linux
xiejay97
Metadata
Metadata
Assignees
Labels
No labels