electron-userland / electron-prebuilt-compile

electron-prebuilt with Babel and React built-in
168 stars 50 forks source link

Forward signals to child process #30

Closed ghost closed 7 years ago

ghost commented 7 years ago

Fixes Electron not exiting when the CLI is spawned as a child process itself and then the parent process is killed via a signal.

Originally, running the following command and then sending a SIGINT to the Node process will cause Electron to remain open even through Node itself dies.

node -e 'const cp = require("child_process").spawn("node", ["./lib/cli.js", "../ELECTRON-APP"], {stdio: "inherit"});process.on("SIGINT", () => cp.kill("SIGINT"));'
anaisbetts commented 7 years ago

I'm not super excited about this, you should use setpgid instead in your host process

ghost commented 7 years ago

The issue that prompted this PR is that I don't control the host process. It's a debugging extension for my IDE.

setpgid is also not portable between all operating systems. Node has no native call for this and the NPM packages that add it are for POSIX-compliant systems only.

anaisbetts commented 7 years ago

Hm, what IDE is this? Can you show me their debugging extension code?

ghost commented 7 years ago

Visual Studio Code, specifically: https://github.com/Microsoft/vscode-chrome-debug

The code that is causing me grief is this spawn call: https://github.com/Microsoft/vscode-chrome-debug/blob/master/src/chromeDebugAdapter.ts#L211