From 3d4eedeb11f2e179df941c01d3099cb691911468 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Fri, 3 Apr 2020 17:00:01 -0700 Subject: [PATCH] List dotnet processes about to be killed (#20526) * List dotnet processes about to be killed This should make it easier to see which test projects are failing to terminate when troubleshooting test hangs. * Enlongenate --- eng/scripts/KillProcesses.ps1 | 9 +++++++++ eng/scripts/KillProcesses.sh | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/eng/scripts/KillProcesses.ps1 b/eng/scripts/KillProcesses.ps1 index 153234abd9..43d7c5ed92 100644 --- a/eng/scripts/KillProcesses.ps1 +++ b/eng/scripts/KillProcesses.ps1 @@ -38,6 +38,15 @@ function _killSeleniumTrackedProcesses() { } } +function _listProcesses($processName) { + $processes = Get-WmiObject win32_process -Filter "name like '%$processName'" -ErrorAction SilentlyContinue; + if ($processes) { + Write-Host "These processes will be killed..." + $processes | select commandline | Out-String -Width 800 + } +} + +_listProcesses dotnet _kill dotnet.exe _kill testhost.exe _kill iisexpress.exe diff --git a/eng/scripts/KillProcesses.sh b/eng/scripts/KillProcesses.sh index f52511739b..e491dc1693 100755 --- a/eng/scripts/KillProcesses.sh +++ b/eng/scripts/KillProcesses.sh @@ -1,4 +1,12 @@ #!/usr/bin/env bash +# list processes that would be killed so they appear in the log +p=$(pgrep dotnet) +if [ $? -eq 0 ] +then + echo "These processes will be killed..." + ps -p $p +fi + pkill dotnet || true exit 0