diff --git a/lib/src/child-writer/writer-proxy.js b/lib/src/child-writer/writer-proxy.js index 21bceacd..c8c4fd9c 100644 --- a/lib/src/child-writer/writer-proxy.js +++ b/lib/src/child-writer/writer-proxy.js @@ -139,10 +139,20 @@ return isElevated().then((elevated) => { return new Bluebird((resolve, reject) => { ipc.config.id = process.env.IPC_CLIENT_ID; ipc.config.silent = true; + + // > If set to 0, the client will NOT try to reconnect. + // See https://github.com/RIAEvangelist/node-ipc/ + // + // The purpose behind this change is for this process + // to emit a "disconnect" event as soon as the GUI + // process is closed, so we can kill the CLI as well. + ipc.config.stopRetrying = 0; + ipc.connectTo(process.env.IPC_SERVER_ID, () => { ipc.of[process.env.IPC_SERVER_ID].on('error', reject); ipc.of[process.env.IPC_SERVER_ID].on('connect', () => { const child = childProcess.spawn(EXECUTABLE, ETCHER_ARGUMENTS); + ipc.of[process.env.IPC_SERVER_ID].on('disconnect', _.bind(child.kill, child)); child.on('error', reject); child.on('close', resolve);