aboutsummaryrefslogtreecommitdiff
path: root/src/platform
diff options
context:
space:
mode:
Diffstat (limited to 'src/platform')
-rw-r--r--src/platform/fallback.rs2
-rw-r--r--src/platform/unix_common.rs10
-rw-r--r--src/platform/windows.rs19
3 files changed, 24 insertions, 7 deletions
diff --git a/src/platform/fallback.rs b/src/platform/fallback.rs
index 2086e2a7..f0e5c2ca 100644
--- a/src/platform/fallback.rs
+++ b/src/platform/fallback.rs
@@ -109,6 +109,8 @@ impl StatusCommandGuard {
pub(crate) fn new(_child: &tokio::process::Child) -> std::io::Result<Self> {
Ok(Self)
}
+
+ pub(crate) fn terminate(&mut self) {}
}
fn raw_command_argv(command: &str, flag: &str) -> Vec<std::ffi::OsString> {
diff --git a/src/platform/unix_common.rs b/src/platform/unix_common.rs
index 3004e6da..fa7b6d20 100644
--- a/src/platform/unix_common.rs
+++ b/src/platform/unix_common.rs
@@ -174,8 +174,8 @@ impl StatusCommandGuard {
}
}
-impl Drop for StatusCommandGuard {
- fn drop(&mut self) {
+impl StatusCommandGuard {
+ pub(crate) fn terminate(&mut self) {
if let Some(process_group_id) = self.process_group_id.take() {
// The command was spawned as this process group's leader. Killing the
// group also cleans up background descendants on completion/cancellation.
@@ -186,6 +186,12 @@ impl Drop for StatusCommandGuard {
}
}
+impl Drop for StatusCommandGuard {
+ fn drop(&mut self) {
+ self.terminate();
+ }
+}
+
fn datetime_from_tm(value: &libc::tm) -> Option<time::PrimitiveDateTime> {
let month = time::Month::try_from(u8::try_from(value.tm_mon + 1).ok()?).ok()?;
let date = time::Date::from_calendar_date(
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<u32>) -> 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();
}
}