microsoft / microsoft/terminal

Process.CloseMainWindow() and Process.Close() are ignored for processes running in terminal

Open
#11,823 8 comments 1 reaction 2 assignees View on GitHub

@zadjii-msft is already working on this.

Since Jan 6, 2023.

Area-Server Issue-Bug Priority-2 Product-Conpty
Dominant language
C++
Stars
105k
Forks
9.6k
Avg merge
3d 17h
Merged PRs (30d)
29

Description

### Windows Terminal version

1.11.2921.0

### Windows build number

10.0.22000.258

### Other Software

.NET Framework 4.7.1

### Steps to reproduce

Configure Terminal as default terminal application.
Write application (in our case .NET framework 4.7.1 WPF application) that starts some other console process:
`var startInfo = new ProcessStartInfo {
UseShellExecute = false
};
var process = new Process {
EnableRaisingEvents = true,
StartInfo = startInfo
};
process.Start();`

then try to stop this process with the following code:
`Process process = Process.GetProcessById(processId);
if (!process.HasExited) {
process.CloseMainWindow();
if (!process.HasExited) {
if (!process.WaitForExit(5000)) {
process.Close();
}
}
}`

### Expected Behavior

Process is stopped and the terminal tab is closed (same as in the case cmd.exe is the default terminal application).

### Actual Behavior

Nothing happens.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.