Proxy child exit code when exiting parent process

This fixes code-server exiting with zero on errors.
This commit is contained in:
Asher 2019-10-28 14:56:37 -05:00
parent ea36345d2c
commit 422503ef98
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A
1 changed files with 4 additions and 1 deletions

View File

@ -204,6 +204,7 @@ export class WrapperProcess {
logger.info("Relaunching..."); logger.info("Relaunching...");
this.started = undefined; this.started = undefined;
if (this.process) { if (this.process) {
this.process.removeAllListeners();
this.process.kill(); this.process.kill();
} }
try { try {
@ -223,7 +224,9 @@ export class WrapperProcess {
public start(): Promise<void> { public start(): Promise<void> {
if (!this.started) { if (!this.started) {
const child = this.spawn(); const child = this.spawn();
this.started = ipcMain.handshake(child); this.started = ipcMain.handshake(child).then(() => {
child.once("exit", (code) => exit(code!));
});
this.process = child; this.process = child;
} }
return this.started; return this.started;