Skip to content
Snippets Groups Projects
Commit 07e0ca96 authored by sof's avatar sof
Browse files

[project @ 1998-05-12 17:04:11 by sof]

fdToHandle: use openFd
parent 6ac8d6fd
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
\section[PosixIO]{Haskell 1.3 POSIX Input/Output Primitives} \section[PosixIO]{Haskell 1.3 POSIX Input/Output Primitives}
\begin{code} \begin{code}
{-# OPTIONS -#include "../std/cbits/stgio.h" #-}
module PosixIO ( module PosixIO (
FdOption(..), FdOption(..),
FileLock, FileLock,
...@@ -109,14 +110,17 @@ fdToHandle fd@(FD# fd#) = ...@@ -109,14 +110,17 @@ fdToHandle fd@(FD# fd#) =
else else
("r",ReadHandle) ("r",ReadHandle)
in in
_ccall_ fdopen fd ft >>= \ file_struct@(A# ptr#) -> _ccall_ openFd fd ft >>= \ file_struct@(A# ptr#) ->
if file_struct /= (``NULL''::Addr) then if file_struct /= (``NULL''::Addr) then
{- {-
A distinction is made here between std{Input,Output,Error} Fds A distinction is made here between std{Input,Output,Error} Fds
and all others. The standard descriptors have a finaliser and all others. The standard descriptors have a finaliser
that will not close the underlying fd, the others have one that will not close the underlying fd, the others have one
that will. Or rather, the closing of the standard descriptors is that will.
delayed until the process exits.
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__ #ifndef __PARALLEL_HASKELL__
(if fd == stdInput || fd == stdOutput || fd == stdError then (if fd == stdInput || fd == stdOutput || fd == stdError then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment