fix(lab): release T-014 process handles before cleanup [T-014]
Harness governance / validate (push) Has been cancelled
Harness governance / validate (push) Has been cancelled
This commit is contained in:
@@ -146,6 +146,29 @@ function Stop-AllManagedProcesses($Items) {
|
||||
if ($remaining.Count -gt 0) {
|
||||
Write-Warning "managed processes did not exit within the shared cleanup deadline: $($remaining.Count)"
|
||||
}
|
||||
foreach ($item in $processes) {
|
||||
if ($item.Process.HasExited) {
|
||||
$item.Stdout.Wait(2000) | Out-Null
|
||||
$item.Stderr.Wait(2000) | Out-Null
|
||||
$item.Process.Dispose()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Remove-SessionDirectory([string]$Path) {
|
||||
Get-ChildItem -LiteralPath $Path -Recurse -Force -ErrorAction SilentlyContinue |
|
||||
ForEach-Object { $_.Attributes = 'Normal' }
|
||||
(Get-Item -LiteralPath $Path -Force).Attributes = 'Directory'
|
||||
$deleteWatch = [Diagnostics.Stopwatch]::StartNew()
|
||||
while (Test-Path -LiteralPath $Path) {
|
||||
try {
|
||||
Remove-Item -LiteralPath $Path -Recurse -Force -ErrorAction Stop
|
||||
}
|
||||
catch {
|
||||
if ($deleteWatch.Elapsed.TotalSeconds -ge 10) { throw }
|
||||
Start-Sleep -Milliseconds 200
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Assert-Alive($Managed) {
|
||||
@@ -920,10 +943,7 @@ finally {
|
||||
throw 'refusing to clean an unexpected T-014 session path'
|
||||
}
|
||||
if (Test-Path -LiteralPath $resolvedSession) {
|
||||
Get-ChildItem -LiteralPath $resolvedSession -Recurse -Force -ErrorAction SilentlyContinue |
|
||||
ForEach-Object { $_.Attributes = 'Normal' }
|
||||
(Get-Item -LiteralPath $resolvedSession -Force).Attributes = 'Directory'
|
||||
Remove-Item -LiteralPath $resolvedSession -Recurse -Force
|
||||
Remove-SessionDirectory $resolvedSession
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user