diff --git a/packages/plugin-ext/src/hosted/node/hosted-plugin-process.ts b/packages/plugin-ext/src/hosted/node/hosted-plugin-process.ts index e8cda321abfe3..3814e46676a91 100644 --- a/packages/plugin-ext/src/hosted/node/hosted-plugin-process.ts +++ b/packages/plugin-ext/src/hosted/node/hosted-plugin-process.ts @@ -25,6 +25,7 @@ import { RPCProtocolImpl } from '../../api/rpc-protocol'; import { MAIN_RPC_CONTEXT } from '../../api/plugin-api'; import { HostedPluginCliContribution } from './hosted-plugin-cli-contribution'; import {HostedPluginProcessesCache} from './hosted-plugin-processes-cache'; +const psTree = require('ps-tree'); export interface IPCConnectionOptions { readonly serverName: string; @@ -122,11 +123,21 @@ export class HostedPluginProcess implements ServerPluginRunner { const hostedPluginManager = rpc.getProxy(MAIN_RPC_CONTEXT.HOSTED_PLUGIN_MANAGER_EXT); hostedPluginManager.$stopPlugin('').then(() => { emitter.dispose(); - cp.kill(); + this.killProcessTree(cp); }); } + private killProcessTree(parentProcess: cp.ChildProcess): void { + const parentPid = parentProcess.pid; + // tslint:disable-next-line:no-any + psTree(parentPid, (err: Error, children: Array) => { + parentProcess.kill(); + // tslint:disable-next-line:no-any + cp.spawn('kill', children.map((p: any) => p.PID)); + }); + } + public runPluginServer(): void { if (this.childProcess) { this.terminatePluginServer();