Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotnet watch process started by auto watch feature not stopped by dotnet-test-explorer.stop on windows #347

Open
allenbenz opened this issue Dec 10, 2021 · 2 comments · May be fixed by #348

Comments

@allenbenz
Copy link

allenbenz commented Dec 10, 2021

dotnet sdk: 6.0.100
nunit: 3.13.2
OS: windows 10
example repo: https://github.com/allenbenz/dotnet-test-explorer-linger-issue

The dotnet watch process isn't stopped when executing dotnet-test-explorer.stop. The cmd shell that started the dotnet watch process is closed however.

Workaround is to kill the dotnet process with task manager.

Reproduction steps:

  1. Enable the auto watch feature
  2. Open vscode in the checked out example repo (where the .sln file is)
  3. Open task manager, observe respective dotnet and cmd entries
  4. Run Stop running processes
  5. Observe dotnet entries still present:
    • dotnet watch test --verbosity:quiet --logger "trx;LogFileName=C:\Users\allen\AppData\Local\Temp\test-explorer-fvHIQG\autoWatch0.trx"
    • "C:\Program Files\dotnet\dotnet.exe" "C:\Program Files\dotnet\sdk\6.0.100\DotnetTools\dotnet-watch\6.0.100-rtm.21527.8\tools\net6.0\any\dotnet-watch.dll" test --verbosity:quiet --logger trx;LogFileName=C:\Users\allen\AppData\Local\Temp\test-explorer-fvHIQG\autoWatch0.trx
@allenbenz allenbenz changed the title dotnet watch process started by auto watch feature lingers after vscode closed dotnet watch process started by auto watch feature lingers after vscode closed on windows Dec 10, 2021
@allenbenz
Copy link
Author

allenbenz commented Dec 10, 2021

Looking into this more, this is specific to windows.
https://serverfault.com/questions/47389/task-scheduler-only-killing-cmd-exe-but-not-its-child-processes
https://stackoverflow.com/questions/32705857/cant-kill-child-process-on-windows

I'm able to reproduce the issue by running
cmd /c "dotnet watch test --project dotnet-test-explorer.sln"
and manually terminating the cmd process.

Using taskkill /pid <cmd pid> /t /f does kill the dotnet child processes.

@allenbenz allenbenz changed the title dotnet watch process started by auto watch feature lingers after vscode closed on windows dotnet watch process started by auto watch feature not stopped by dotnet-test-explorer.stop on windows Dec 10, 2021
@allenbenz
Copy link
Author

allenbenz commented Dec 10, 2021

Dropping

              if (this.isWindows) {
                  child_process.exec('taskkill /pid ' + p.pid + ' /T /F')
              } else {
                  p.kill("SIGKILL");
              }

in the stop method fixes the dotnet-test-explorer.stop command.

Not sure what vscode does on close but it has the same problem and it's not killing the child processes either, but that's a separate issue.

@allenbenz allenbenz linked a pull request Dec 11, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant