Skip to content

Commit 5375f57

Browse files
committed
fix: send ctrl+c to kill nodemon running in debug term
Fixes #108289
1 parent 60c4b00 commit 5375f57

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

src/targets/node/terminalNodeLauncher.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@
22
* Copyright (C) Microsoft Corporation. All rights reserved.
33
*--------------------------------------------------------*/
44

5+
import { randomBytes } from 'crypto';
56
import { inject, injectable } from 'inversify';
7+
import { tmpdir } from 'os';
68
import * as path from 'path';
79
import * as vscode from 'vscode';
810
import { DebugType } from '../../common/contributionUtils';
911
import { EventEmitter } from '../../common/events';
12+
import { IFsUtils } from '../../common/fsUtils';
13+
import { ILogger } from '../../common/logging';
1014
import { AnyLaunchConfiguration, ITerminalLaunchConfiguration } from '../../configuration';
1115
import { ErrorCodes } from '../../dap/errors';
1216
import { ProtocolError } from '../../dap/protocolError';
13-
import { tmpdir } from 'os';
14-
import { randomBytes } from 'crypto';
1517
import { FS, FsPromises } from '../../ioc-extras';
18+
import { IStopMetadata, ITarget } from '../targets';
1619
import {
1720
hideDebugInfoFromConsole,
1821
INodeBinaryProvider,
19-
NodeBinaryProvider,
2022
NodeBinary,
23+
NodeBinaryProvider,
2124
} from './nodeBinaryProvider';
22-
import { ILogger } from '../../common/logging';
23-
import { IFsUtils } from '../../common/fsUtils';
25+
import { IProcessTelemetry, IRunData, NodeLauncherBase } from './nodeLauncherBase';
2426
import { IProgram } from './program';
25-
import { IStopMetadata, ITarget } from '../targets';
26-
import { NodeLauncherBase, IProcessTelemetry, IRunData } from './nodeLauncherBase';
2727

2828
class VSCodeTerminalProcess implements IProgram {
2929
public readonly stopped: Promise<IStopMetadata>;
@@ -44,7 +44,11 @@ class VSCodeTerminalProcess implements IProgram {
4444
}
4545

4646
public stop() {
47-
this.terminal.dispose();
47+
// send ctrl+c to sigint any running processs (vscode/#108289)
48+
this.terminal.sendText('\x03');
49+
// and then destroy it on the next event loop tick
50+
setTimeout(() => this.terminal.dispose(), 1);
51+
4852
return this.stopped;
4953
}
5054
}
@@ -136,11 +140,17 @@ export class TerminalNodeLauncher extends NodeLauncherBase<ITerminalLaunchConfig
136140
this.terminalCreatedEmitter.fire(terminal);
137141

138142
terminal.show();
139-
this.program = new VSCodeTerminalProcess(terminal);
143+
const program = (this.program = new VSCodeTerminalProcess(terminal));
140144

141145
if (runData.params.command) {
142146
terminal.sendText(runData.params.command, true);
143147
}
148+
149+
program.stopped.then(result => {
150+
if (program === this.program) {
151+
this.onProgramTerminated(result);
152+
}
153+
});
144154
}
145155

146156
/**

0 commit comments

Comments
 (0)