Skip to content

Commit bb9970e

Browse files
committed
Put the service stop under 60 second timer as well.
1 parent db0b125 commit bb9970e

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

‎ci/tools/configure_driver_mode.ps1‎

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,26 @@ function Stop-DisplayContainer {
1616
# A crash-looping display-container process can race the subsequent device
1717
# cycle and prevent the NVIDIA kernel driver from unloading.
1818
Write-Output "Stopping NVDisplay.ContainerLocalSystem..."
19-
Stop-Service -Name "NVDisplay.ContainerLocalSystem" -Force -ErrorAction Stop
20-
21-
Write-Output "Waiting for NVDisplay.Container processes to exit..."
19+
$service = Get-Service -Name "NVDisplay.ContainerLocalSystem" -ErrorAction Stop
2220
$deadline = (Get-Date).AddSeconds(60)
23-
$container_processes = @(Get-Process -Name "NVDisplay.Container" -ErrorAction SilentlyContinue)
24-
while ($container_processes.Count -gt 0 -and (Get-Date) -lt $deadline) {
25-
Start-Sleep -Milliseconds 500
26-
$container_processes = @(Get-Process -Name "NVDisplay.Container" -ErrorAction SilentlyContinue)
21+
if ($service.Status -ne "Stopped" -and $service.Status -ne "StopPending") {
22+
Stop-Service -InputObject $service -Force -NoWait -ErrorAction Stop
2723
}
28-
if ($container_processes.Count -gt 0) {
29-
$process_ids = $container_processes.Id -join ", "
30-
Write-Error "NVDisplay.Container processes ($process_ids) did not exit within 60s of stopping NVDisplay.ContainerLocalSystem"
31-
exit 1
24+
25+
Write-Output "Waiting for NVDisplay.ContainerLocalSystem to stop and NVDisplay.Container processes to exit..."
26+
while ($true) {
27+
$service.Refresh()
28+
$container_processes = @(Get-Process -Name "NVDisplay.Container" -ErrorAction SilentlyContinue)
29+
if ($service.Status -eq "Stopped" -and $container_processes.Count -eq 0) {
30+
break
31+
}
32+
if ((Get-Date) -ge $deadline) {
33+
$process_ids = $container_processes.Id -join ", "
34+
if (-not $process_ids) { $process_ids = "none" }
35+
Write-Error "Timed out after 60s waiting for the NVIDIA display container (service status: $($service.Status); remaining NVDisplay.Container PIDs: $process_ids)"
36+
exit 1
37+
}
38+
Start-Sleep -Milliseconds 500
3239
}
3340
}
3441

0 commit comments

Comments
 (0)