From 07e0ca96d26a1e317acf95497db83de0a217d5f8 Mon Sep 17 00:00:00 2001
From: sof <unknown>
Date: Tue, 12 May 1998 17:04:11 +0000
Subject: [PATCH] [project @ 1998-05-12 17:04:11 by sof] fdToHandle: use openFd

---
 ghc/lib/posix/PosixIO.lhs | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/ghc/lib/posix/PosixIO.lhs b/ghc/lib/posix/PosixIO.lhs
index 6c2ce723c190..6c67b24d1c37 100644
--- a/ghc/lib/posix/PosixIO.lhs
+++ b/ghc/lib/posix/PosixIO.lhs
@@ -4,6 +4,7 @@
 \section[PosixIO]{Haskell 1.3 POSIX Input/Output Primitives}
 
 \begin{code}
+{-# OPTIONS -#include "../std/cbits/stgio.h" #-}
 module PosixIO (
     FdOption(..),
     FileLock,
@@ -109,14 +110,17 @@ fdToHandle fd@(FD# fd#) =
 	else
 	  ("r",ReadHandle)
       in
-      _ccall_ fdopen fd ft >>= \ file_struct@(A# ptr#) ->
+      _ccall_ openFd fd ft >>= \ file_struct@(A# ptr#) ->
       if file_struct /= (``NULL''::Addr) then
 	 {-
 	   A distinction is made here between std{Input,Output,Error} Fds
 	   and all others. The standard descriptors have a finaliser
 	   that will not close the underlying fd, the others have one
-	   that will. Or rather, the closing of the standard descriptors is
-	   delayed until the process exits.
+	   that will. 
+
+	   Delaying the closing of the standard descriptors until the process
+	   exits is necessary since the RTS is likely to require these after
+	   (or as a result of) program termination.
 	 -}
 #ifndef __PARALLEL_HASKELL__
 	 (if fd == stdInput || fd == stdOutput || fd == stdError then
-- 
GitLab