# rig45_down.ps1 -- tear down ONLY the PIDs rig45_up.ps1 recorded. # Deliberately does NOT use Get-Process -Name / Stop-Process by name: a blanket # name kill once destroyed a live tester session. If a PID has been recycled to # a different image, it is skipped. $ErrorActionPreference = 'Continue' $scratch = 'C:\Users\EPILECTRIK\AppData\Local\Temp\claude\C--git-bt411\89ab96e9-6cf0-4555-939d-05bf3708745a\scratchpad' $pidfile = Join-Path $scratch 'rig45_pids.txt' if (-not (Test-Path $pidfile)) { "no pidfile -- nothing recorded, nothing killed"; exit 0 } foreach ($line in Get-Content $pidfile) { $procId = 0 if (-not [int]::TryParse($line.Trim(), [ref]$procId)) { continue } $p = Get-Process -Id $procId -ErrorAction SilentlyContinue if (-not $p) { "pid $procId already gone"; continue } # Only kill it if it is still one of the images this rig launches. if ($p.ProcessName -notin @('btl4','python')) { "pid $procId is now '$($p.ProcessName)' -- PID recycled, SKIPPING" continue } Stop-Process -Id $procId -Confirm:$false -ErrorAction SilentlyContinue Start-Sleep -Milliseconds 300 if (Get-Process -Id $procId -ErrorAction SilentlyContinue) { "pid $procId ($($p.ProcessName)) DID NOT DIE" } else { "killed pid $procId ($($p.ProcessName))" } } Remove-Item $pidfile -ErrorAction SilentlyContinue "teardown complete"