Skip to content

Electron: Python backend orphaned on non-graceful exit (no group kill / SIGKILL fallback) #39

Description

@I4cTime

Summary

The Python child is not spawned detached in its own process group and is not reaped; the only cleanup is a single SIGTERM on before-quit with no wait and no SIGKILL fallback.

Location

electron/main.ts:144, 452-455

Evidence

pythonProcess = spawn(cmd, args, { env, stdio: ["pipe","pipe","pipe"] });   // no detached / group handling
...
app.on("before-quit", () => { if (pythonProcess) { pythonProcess.kill("SIGTERM"); pythonProcess = null; } });

Failure scenario

User force-quits the app or it crashes (SIGKILL, OOM) -> before-quit never runs -> the backend keeps running orphaned, holding its port and potentially still mutating system state. Even on clean quit, a backend slow to handle SIGTERM is never force-killed.

Fix

Spawn detached in its own group and kill the group; add a SIGKILL fallback after a timeout; consider a parent-death watchdog on the Python side.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: electronElectron shell / main / preloadbugSomething isn't workingseverity: mediumMedium severity

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions