vscode-dotnet-test-explorer icon indicating copy to clipboard operation
vscode-dotnet-test-explorer copied to clipboard

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

Open allenbenz opened this issue 3 years ago • 2 comments

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 avatar Dec 10 '21 19:12 allenbenz

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 avatar Dec 10 '21 20:12 allenbenz

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 avatar Dec 10 '21 20:12 allenbenz