$OpenBSD: patch-lib_Processes_hs,v 1.1.1.1 2004/05/09 10:30:22 dons Exp $

fix code to follow semantics of post 6.2 forkProcess

--- lib/Processes.hs.orig	2004-05-07 13:32:22.000000000 +1000
+++ lib/Processes.hs	2004-05-07 13:47:33.000000000 +1000
@@ -1,3 +1,4 @@
+{-# OPTIONS -cpp #-}
 --  Haskell Ports Library: Process management
 --
 --  Author : Manuel M T Chakravarty
@@ -304,10 +305,8 @@ forkExec path args env =
     (stdinReadFD , stdinWriteFD ) <- createPipe
     (stdoutReadFD, stdoutWriteFD) <- createPipe
     (stderrReadFD, stderrWriteFD) <- createPipe
-    pid <- forkProcess
-    case pid of
-      Nothing  ->			-- child process
-        do
+
+    let child = do
 	  dupTo stdinReadFD   stdInput
           dupTo stdoutWriteFD stdOutput
           dupTo stderrWriteFD stdError
@@ -316,8 +315,8 @@ forkExec path args env =
 			 stderrReadFD, stderrWriteFD]
           executeFile path True args env
 	  error "Processes.forkExec: executeFile: failed"
-      Just pid ->			-- parent process
-        do
+
+    let parent pid = do
 	  mapM_ closeFd [stdinReadFD, stdoutWriteFD, stderrWriteFD]
 	  mapM_ (\fd -> setFdOption fd CloseOnExec True) 
 		[stdinWriteFD, stdoutReadFD, stderrReadFD]
@@ -326,6 +325,15 @@ forkExec path args env =
 	  stderrReadHandle  <- fdToHandle stderrReadFD
 	  return (pid, stdinWriteHandle, stdoutReadHandle, stderrReadHandle)
 
+#if __GLASGOW_HASKELL__ >= 601
+    pid <- forkProcess child -- fork child
+    parent pid               -- and run parent code
+#else
+    pid <- forkProcess
+    case pid of
+        Just pid -> parent pid
+        Nothing  -> child
+#endif
 
 -- auxilliary routines for debugging
 -- ---------------------------------
