Child processes are orphaned when stop debugging
- Dominant language
- TypeScript
- Stars
- 3.1k
- Forks
- 737
- Avg merge
- 18h 40m
- Merged PRs (30d)
- 31
Description
## Issue Description ##
I have setup a launch json and when I press F5 it uses `Process.Start` to create some long running child procesess. If I detach the debugger my application process is killed, but the child processes are orphaned. These processes hold open fixed ports and simply pressing F5 a second time crashes the app since the ports are already open.
## Steps to Reproduce ##
I can make a reproduction but its fairly complicated... But something like:
1. Make a C# console app that shell exec's an app that opens a port:
```cs
Process.Start("kubectl", "port-forward service/example 8080").WaitForExit();
```
2. Create a standard launch.json and hit `F5`
3. `Shift+F5` (detach debugger)
4. Press `F5` again
## Expected Behavior ##
The app successfully runs a second time and child processes are able to open their respective ports.
## Actual Behavior ##
Child processes remain running and ports are locked.
## Logs ##
```
[example] Unable to listen on port 8080: Listeners failed to create with the following errors: [unable to create listener: Error listen tcp4 127.0.0.1:8080: bind: address already in use unable to create listener: Error listen tcp6 [::1]:8080: bind: address already in use]
[example] error: unable to listen on any of the requested ports: [{8080 8080}]
```
### OmniSharp log ###
N/A
### C# log ###
N/A
## Environment information ##
**VSCode version**: 1.52.0
**C# Extension**: 1.23.8
Mono Information
OmniSharp using built-in mono
Dotnet Information
.NET Core SDK (reflecting any global.json):
Version: 3.1.404
Commit: 470f6754b3
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.15
OS Platform: Darwin
RID: osx.10.15-x64
Base Path: /usr/local/share/dotnet/sdk/3.1.404/
Host (useful for support):
Version: 3.1.10
Commit: 1721e39439
.NET Core SDKs installed:
3.1.404 [/usr/local/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.10 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.10 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
Visual Studio Code Extensions
|Extension|Author|Version|
|---|---|---|
|csharp|ms-dotnettools|1.23.8|
|debugger-for-chrome|msjsdiag|4.12.11|
|githistory|donjayamanne|0.6.14|
|gitlens|eamodio|11.1.0|
|insert-unicode|brunnerh|0.10.0|
|prettify-json|mohsen1|0.0.3|
|remote-containers|ms-vscode-remote|0.154.1|
|vscode-docker|ms-azuretools|1.9.0|
|vscode-nuget-package-manager|jmrog|1.1.6|;
Contributor guide
Assessment
This issue has not been assessed yet.