Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Fix microsoft/vscode#57018 - create a new process group and kill the …
Browse files Browse the repository at this point in the history
…group
  • Loading branch information
roblourens committed Aug 22, 2018
1 parent a84651c commit 55d7ca0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/nodeDebugAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ export class NodeDebugAdapter extends ChromeDebugAdapter {
return this._attachMode && !this.isExtensionHost();
}

private get supportsTerminateRequest(): boolean {
return process.platform !== 'win32' && !this.isExtensionHost();
}

public initialize(args: DebugProtocol.InitializeRequestArguments): DebugProtocol.Capabilities {
this._adapterID = args.adapterID;
this._promiseRejectExceptionFilterEnabled = this.isExtensionHost();
Expand All @@ -75,7 +79,7 @@ export class NodeDebugAdapter extends ChromeDebugAdapter {

const capabilities = super.initialize(args);
capabilities.supportsLogPoints = true;
capabilities.supportsTerminateRequest = process.platform !== 'win32' && !this.isExtensionHost();
capabilities.supportsTerminateRequest = this.supportsTerminateRequest;

return capabilities;
}
Expand Down Expand Up @@ -351,6 +355,7 @@ export class NodeDebugAdapter extends ChromeDebugAdapter {
}

this.logLaunchCommand(runtimeExecutable, launchArgs);
spawnOpts.detached = this.supportsTerminateRequest; // https://github.com/Microsoft/vscode/issues/57018
const nodeProcess = cp.spawn(runtimeExecutable, launchArgs, spawnOpts);
return new Promise<void>((resolve, reject) => {
this._nodeProcessId = nodeProcess.pid;
Expand Down Expand Up @@ -515,7 +520,10 @@ export class NodeDebugAdapter extends ChromeDebugAdapter {

public async terminate(args: DebugProtocol.TerminateArguments): Promise<void> {
if (!this._attachMode && !(<ILaunchRequestArguments>this._launchAttachArgs).useWSL && this._nodeProcessId > 0) {
process.kill(this._nodeProcessId, 'SIGINT');
// -pid to kill the process group
// https://github.com/Microsoft/vscode/issues/57018
const groupPID = -this._nodeProcessId;
process.kill(groupPID, 'SIGINT');
}
}

Expand Down

0 comments on commit 55d7ca0

Please sign in to comment.