From 8d190f0772c870e40d9d67fe4e1cbbb7eafb1f6b Mon Sep 17 00:00:00 2001 From: Quinton Miller Date: Mon, 20 Nov 2023 22:09:03 +0800 Subject: [PATCH] Windows: Do not close process handle in `Process#close` --- spec/std/process_spec.cr | 4 +--- src/crystal/system/win32/process.cr | 2 ++ src/process.cr | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/spec/std/process_spec.cr b/spec/std/process_spec.cr index 7ce5f3849a39..94b8ec18a915 100644 --- a/spec/std/process_spec.cr +++ b/spec/std/process_spec.cr @@ -333,9 +333,7 @@ describe Process do {% end %} end - # TODO: this spec gives "WaitForSingleObject: The handle is invalid." - # is this because standard streams on windows aren't async? - pending_win32 "can link processes together" do + it "can link processes together" do buffer = IO::Memory.new Process.run(*stdin_to_stdout_command) do |cat| Process.run(*stdin_to_stdout_command, input: cat.output, output: buffer) do diff --git a/src/crystal/system/win32/process.cr b/src/crystal/system/win32/process.cr index b92203b38510..e6bb417a87c0 100644 --- a/src/crystal/system/win32/process.cr +++ b/src/crystal/system/win32/process.cr @@ -95,6 +95,8 @@ struct Crystal::System::Process raise "BUG: Process still active" end exit_code + ensure + release end def exists? diff --git a/src/process.cr b/src/process.cr index 159b08b39eaa..603866bdeebd 100644 --- a/src/process.cr +++ b/src/process.cr @@ -346,7 +346,6 @@ class Process close_io @input close_io @output close_io @error - @process_info.release end # Asks this process to terminate.