From 1464d461724198a49ac311e154078c37a7d63369 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 10 May 2026 12:35:21 +0000 Subject: [PATCH] fix: kill and wait stremio-runtime child after readers finish After both stdout and stderr readers exited, the Child handle was just dropped at the end of the match arm. On Windows std::process::Child's Drop neither kills nor waits, so the OS process kept its kernel object (and its bound ports) alive until either the JobObject KILL_ON_JOB_CLOSE fired on shell exit or init adopted it. In the crash-restart path this is worse: a fresh start() is launched while the previous runtime is still being reaped, and both processes race for port 11470. Explicitly kill().ok() + wait().ok() once the readers see EOF so the previous runtime is gone before we report 'Server terminated.' and fire the crash notice. Errors from killing an already-exited child are intentionally swallowed. Closes #50 --- src/stremio_app/stremio_server/server.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/stremio_app/stremio_server/server.rs b/src/stremio_app/stremio_server/server.rs index c59b273..d942b1b 100644 --- a/src/stremio_app/stremio_server/server.rs +++ b/src/stremio_app/stremio_server/server.rs @@ -178,6 +178,9 @@ impl StremioServer { }); out_thread.join().ok(); err_thread.join().ok(); + // Drop on Windows neither kills nor waits, so reap explicitly. + child.kill().ok(); + child.wait().ok(); } Err(err) => { nwg::error_message(