From 1518d631150a969041095d71cc8381bff6157b47 Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@factorcode.org>
Date: Sun, 6 Apr 2008 22:04:31 -0500
Subject: [PATCH] Fix Windows launcher resource leak

---
 extra/io/windows/nt/launcher/launcher-tests.factor | 13 ++++++++++++-
 extra/io/windows/nt/launcher/launcher.factor       |  2 +-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/extra/io/windows/nt/launcher/launcher-tests.factor b/extra/io/windows/nt/launcher/launcher-tests.factor
index fac6471b8c..8b13b9b3b9 100755
--- a/extra/io/windows/nt/launcher/launcher-tests.factor
+++ b/extra/io/windows/nt/launcher/launcher-tests.factor
@@ -1,7 +1,7 @@
 IN: io.windows.launcher.nt.tests
 USING: io.launcher tools.test calendar accessors
 namespaces kernel system arrays io io.files io.encodings.ascii
-sequences parser assocs hashtables ;
+sequences parser assocs hashtables math ;
 
 [ ] [
     <process>
@@ -129,3 +129,14 @@ sequences parser assocs hashtables ;
 
     "HOME" swap at "XXX" =
 ] unit-test
+
+2 [
+    [ ] [
+        <process>
+            "cmd.exe /c dir" >>command
+            "dir.txt" temp-file >>stdout
+        try-process
+    ] unit-test
+
+    [ ] [ "dir.txt" temp-file delete-file ] unit-test
+] times
diff --git a/extra/io/windows/nt/launcher/launcher.factor b/extra/io/windows/nt/launcher/launcher.factor
index a01ba4698e..97de248d24 100755
--- a/extra/io/windows/nt/launcher/launcher.factor
+++ b/extra/io/windows/nt/launcher/launcher.factor
@@ -39,7 +39,7 @@ IN: io.windows.nt.launcher
     create-mode
     FILE_ATTRIBUTE_NORMAL ! flags and attributes
     f ! template file
-    CreateFile dup invalid-handle? dup close-later ;
+    CreateFile dup invalid-handle? dup close-always ;
 
 : set-inherit ( handle ? -- )
     >r HANDLE_FLAG_INHERIT r> >BOOLEAN SetHandleInformation win32-error=0/f ;