From d34713b40e611d4d1817943820a13742f07fdb57 Mon Sep 17 00:00:00 2001 From: DuProcess <273172371+DuProcess@users.noreply.github.com> Date: Thu, 16 Jul 2026 22:04:10 -0400 Subject: [PATCH] Avoid stale PID wait in Windows updater --- src/bin/dosh-client.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/bin/dosh-client.rs b/src/bin/dosh-client.rs index a611448..f37acf7 100644 --- a/src/bin/dosh-client.rs +++ b/src/bin/dosh-client.rs @@ -4811,10 +4811,10 @@ fn windows_deferred_update_script(parent_pid: u32, installer_script: &str) -> St $ProgressPreference='SilentlyContinue';\ $parent=Get-Process -Id {parent_pid} -ErrorAction SilentlyContinue;\ $parentStart=if ($parent) {{ $parent.StartTime }} else {{ $null }};\ - while ($true) {{ \ + while ($parentStart) {{ \ $current=Get-Process -Id {parent_pid} -ErrorAction SilentlyContinue;\ if (-not $current) {{ break }};\ - if ($parentStart -and $current.StartTime -ne $parentStart) {{ break }};\ + if ($current.StartTime -ne $parentStart) {{ break }};\ Start-Sleep -Milliseconds 100 \ }};\ {installer_script}" @@ -13180,12 +13180,11 @@ mod tests { assert!( deferred.contains("$parentStart=if ($parent) { $parent.StartTime } else { $null }") ); + assert!(deferred.contains("while ($parentStart)")); assert!(deferred.contains("$current=Get-Process -Id 4242 -ErrorAction SilentlyContinue")); assert!(deferred.contains("if (-not $current) { break }")); - assert!( - deferred - .contains("if ($parentStart -and $current.StartTime -ne $parentStart) { break }") - ); + assert!(deferred.contains("if ($current.StartTime -ne $parentStart) { break }")); + assert!(!deferred.contains("while ($true)")); assert!(deferred.contains("Start-Sleep -Milliseconds 100")); assert!( deferred.contains(