aboutsummaryrefslogtreecommitdiffhomepage
path: root/System/Posix/IO.hsc
diff options
context:
space:
mode:
authorGravatar Simon Marlow <marlowsd@gmail.com>2010-03-19 21:08:02 +0000
committerGravatar Simon Marlow <marlowsd@gmail.com>2010-03-19 21:08:02 +0000
commitf4d4f4e73e835ecba00d0f0f9a5fd298bb5037a3 (patch)
tree7f9cf3f848351988b167ef643d43ccc2230fafc4 /System/Posix/IO.hsc
parent2e147b0cf3567c5a401670b9bbcd95665aadd024 (diff)
handleToFd: close both sides of a DuplexHandle (#3914)
Diffstat (limited to 'System/Posix/IO.hsc')
-rw-r--r--System/Posix/IO.hsc11
1 files changed, 10 insertions, 1 deletions
diff --git a/System/Posix/IO.hsc b/System/Posix/IO.hsc
index 839ec4f..7835b18 100644
--- a/System/Posix/IO.hsc
+++ b/System/Posix/IO.hsc
@@ -238,7 +238,16 @@ fdToHandle :: Fd -> IO Handle
#ifdef __GLASGOW_HASKELL__
#if __GLASGOW_HASKELL__ >= 611
-handleToFd h = withHandle "handleToFd" h $ \ h_@Handle__{haType=_,..} -> do
+handleToFd h@(FileHandle _ m) = do
+ withHandle' "handleToFd" h m $ handleToFd' h
+handleToFd h@(DuplexHandle _ r w) = do
+ withHandle' "handleToFd" h r $ handleToFd' h
+ withHandle' "handleToFd" h w $ handleToFd' h
+ -- for a DuplexHandle, make sure we mark both sides as closed,
+ -- otherwise a finalizer will come along later and close the other
+ -- side. (#3914)
+
+handleToFd' h h_@Handle__{haType=_,..} = do
case cast haDevice of
Nothing -> ioError (ioeSetErrorString (mkIOError IllegalOperation
"handleToFd" (Just h) Nothing)