Skip to content

Commit eb75748

Browse files
authored
only apply graceful kill setting to linux/macOS (microsoft#250639)
1 parent 0ef2804 commit eb75748

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

src/vs/platform/terminal/node/terminalProcess.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -391,19 +391,7 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess
391391
}
392392

393393
private async _killGracefully(ptyProcess: IPty): Promise<void> {
394-
if (!isWindows) {
395-
ptyProcess.kill('SIGTERM');
396-
} else if (isWindows && process.platform === 'win32') {
397-
const windir = process.env['WINDIR'] || 'C:\\Windows';
398-
const TASK_KILL = path.join(windir, 'System32', 'taskkill.exe');
399-
try {
400-
await exec(`${TASK_KILL} /T /PID ${ptyProcess.pid}`);
401-
} catch (err) {
402-
ptyProcess.kill();
403-
}
404-
} else {
405-
ptyProcess.kill();
406-
}
394+
ptyProcess.kill('SIGTERM');
407395
}
408396

409397
private async _throttleKillSpawn(): Promise<void> {

src/vs/workbench/contrib/terminal/browser/terminalInstance.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
567567
this._setAriaLabel(this.xterm?.raw, this._instanceId, this.title);
568568
}
569569
if (e.affectsConfiguration(TerminalSettingId.KillGracefully)) {
570-
this.shellLaunchConfig.killGracefully = this._configurationService.getValue(TerminalSettingId.KillGracefully);
570+
// For windows, we already attempt to gracefully kill the process
571+
this.shellLaunchConfig.killGracefully = !isWindows && this._configurationService.getValue(TerminalSettingId.KillGracefully);
571572
}
572573
if (e.affectsConfiguration('terminal.integrated')) {
573574
this.updateConfig();
@@ -1509,7 +1510,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
15091510
message: nls.localize('workspaceNotTrustedCreateTerminalCwd', "Cannot launch a terminal process in an untrusted workspace with cwd {0} and userHome {1}", this._cwd, this._userHome)
15101511
});
15111512
}
1512-
this.shellLaunchConfig.killGracefully = this._configurationService.getValue(TerminalSettingId.KillGracefully);
1513+
// For windows, we already attempt to gracefully kill the process
1514+
this.shellLaunchConfig.killGracefully = !isWindows && this._configurationService.getValue(TerminalSettingId.KillGracefully);
15131515
// Re-evaluate dimensions if the container has been set since the xterm instance was created
15141516
if (this._container && this._cols === 0 && this._rows === 0) {
15151517
this._initDimensions();

src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ const terminalConfiguration: IConfigurationNode = {
645645
default: false,
646646
markdownDescription: localize(
647647
'terminal.integrated.killGracefully',
648-
'Controls how terminal processes are terminated. When enabled, attempts a graceful shutdown of the process tree. On POSIX, this will send \`SIGTERM\`. On Windows, it uses \`taskkill.exe\` without the \`/F\` (force) flag. Note that this may allow misbehaving processes to remain running. When disabled (default), processes are terminated with: \`SIGHUP\`.'
648+
'Controls how terminal processes are terminated on macOS and Linux. When enabled, attempts a graceful shutdown of the process tree. This will send \`SIGTERM\`. When disabled (default), processes are terminated with: \`SIGHUP\`.'
649649
),
650650
},
651651
...terminalContribConfiguration,

0 commit comments

Comments
 (0)