From 3f752a72fdd073d875cf941e3049f9860e30d841 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Wed, 12 Aug 2026 03:52:41 +0300 Subject: fix: synchronously terminate cancelled status commands --- src/platform/windows.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/platform/windows.rs') diff --git a/src/platform/windows.rs b/src/platform/windows.rs index 12ed784e..83f85e6a 100644 --- a/src/platform/windows.rs +++ b/src/platform/windows.rs @@ -687,13 +687,22 @@ fn resume_suspended_process(process_id: Option) -> std::io::Result<()> { result } +impl StatusCommandGuard { + pub(crate) fn terminate(&mut self) { + if self.job != 0 { + // KILL_ON_JOB_CLOSE terminates the shell and every descendant still in + // the job, including on task cancellation and config reload. + unsafe { + CloseHandle(self.job as HANDLE); + } + self.job = 0; + } + } +} + impl Drop for StatusCommandGuard { fn drop(&mut self) { - // KILL_ON_JOB_CLOSE terminates the shell and every descendant still in - // the job, including on task cancellation and config reload. - unsafe { - CloseHandle(self.job as HANDLE); - } + self.terminate(); } } -- cgit v1.2.3