Getting the file descriptor of a handle, without closing it

2012-03-10 Thread Volker Wysk
Hello! A few months ago, I started a discussion about how to extract the file descriptor of a handle, without the side effect of closing the handle. Bas van Dijk kindly provided the following function: unsafeWithHandleFd :: Handle - (Fd - IO a) - IO a (The action in the second argument is

Re: Getting the file descriptor of a handle, without closing it

2012-03-10 Thread Volker Wysk
Hi This is an addition to my previous post. This modified version of main seems to work: main = do fd - unsafeWithHandleFd stdin return putStrLn (stdin: fd = ++ show fd) fd - unsafeWithHandleFd stdout return putStrLn (stdout: fd = ++ show fd) The way I understand it,

Re: Getting the file descriptor of a handle, without closing it

2012-03-10 Thread John Meacham
Can you use 'dup' to copy the file descriptor and return that version? That will keep a reference to the file even if haskell closes the original descriptor. John On Sat, Mar 10, 2012 at 5:31 PM, Volker Wysk p...@volker-wysk.de wrote: Hi This is an addition to my previous post. This