Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions src/vs/platform/terminal/node/terminalProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,19 +391,7 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess
}

private async _killGracefully(ptyProcess: IPty): Promise<void> {
if (!isWindows) {
ptyProcess.kill('SIGTERM');
} else if (isWindows && process.platform === 'win32') {
const windir = process.env['WINDIR'] || 'C:\\Windows';
const TASK_KILL = path.join(windir, 'System32', 'taskkill.exe');
try {
await exec(`${TASK_KILL} /T /PID ${ptyProcess.pid}`);
} catch (err) {
ptyProcess.kill();
}
} else {
ptyProcess.kill();
}
ptyProcess.kill('SIGTERM');
}

private async _throttleKillSpawn(): Promise<void> {
Expand Down
6 changes: 4 additions & 2 deletions src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._setAriaLabel(this.xterm?.raw, this._instanceId, this.title);
}
if (e.affectsConfiguration(TerminalSettingId.KillGracefully)) {
this.shellLaunchConfig.killGracefully = this._configurationService.getValue(TerminalSettingId.KillGracefully);
// For windows, we already attempt to gracefully kill the process
this.shellLaunchConfig.killGracefully = !isWindows && this._configurationService.getValue(TerminalSettingId.KillGracefully);
}
if (e.affectsConfiguration('terminal.integrated')) {
this.updateConfig();
Expand Down Expand Up @@ -1509,7 +1510,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
message: nls.localize('workspaceNotTrustedCreateTerminalCwd', "Cannot launch a terminal process in an untrusted workspace with cwd {0} and userHome {1}", this._cwd, this._userHome)
});
}
this.shellLaunchConfig.killGracefully = this._configurationService.getValue(TerminalSettingId.KillGracefully);
// For windows, we already attempt to gracefully kill the process
this.shellLaunchConfig.killGracefully = !isWindows && this._configurationService.getValue(TerminalSettingId.KillGracefully);
// Re-evaluate dimensions if the container has been set since the xterm instance was created
if (this._container && this._cols === 0 && this._rows === 0) {
this._initDimensions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ const terminalConfiguration: IConfigurationNode = {
default: false,
markdownDescription: localize(
'terminal.integrated.killGracefully',
'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\`.'
'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\`.'
),
},
...terminalContribConfiguration,
Expand Down
Loading