mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 19:44:25 +01:00
prevent an extension from process.exit() (fixes #411)
This commit is contained in:
@@ -55,6 +55,12 @@ export interface IInitData {
|
||||
};
|
||||
}
|
||||
|
||||
const nativeExit = process.exit;
|
||||
process.exit = () => { console.warn('An extension called process.exit() and this was prevented'); };
|
||||
export function exit(code?: number) {
|
||||
nativeExit(code);
|
||||
}
|
||||
|
||||
export function createServices(remoteCom: IPluginsIPC, initData: IInitData, sharedProcessClient: Client): IInstantiationService {
|
||||
// the init data is not demarshalled
|
||||
initData = marshalling.deserialize(initData);
|
||||
@@ -249,7 +255,7 @@ export class PluginHostMain {
|
||||
|
||||
private gracefulExit(): void {
|
||||
// to give the PH process a chance to flush any outstanding console
|
||||
// messages to the main process, we delay the process.exit() by some time
|
||||
setTimeout(() => process.exit(), 500);
|
||||
// messages to the main process, we delay the exit() by some time
|
||||
setTimeout(() => exit(), 500);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import {onUnexpectedError} from 'vs/base/common/errors';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { PluginHostMain, createServices, IInitData } from 'vs/workbench/node/pluginHostMain';
|
||||
import { PluginHostMain, createServices, IInitData, exit } from 'vs/workbench/node/pluginHostMain';
|
||||
import { Client, connect } from 'vs/base/node/service.net';
|
||||
import { create as createIPC, IPluginsIPC } from 'vs/platform/plugins/common/ipcRemoteCom';
|
||||
|
||||
@@ -50,7 +50,7 @@ function connectToRenderer(): TPromise<IRendererConnection> {
|
||||
try {
|
||||
process.kill(msg.parentPid, 0); // throws an exception if the main process doesn't exist anymore.
|
||||
} catch (e) {
|
||||
process.exit();
|
||||
exit();
|
||||
}
|
||||
}, 5000);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user