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

2012-03-12 Thread Simon Marlow
On 11/03/2012 01:31, Volker Wysk wrote: 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 = ++

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

2012-03-12 Thread Volker Wysk
Am Montag 12 März 2012, 12:31:27 schrieb Simon Marlow: On 11/03/2012 01:31, Volker Wysk wrote: However, I want to use it with stdin, stdout and stderr, only. Is there some reason you can't just use 0, 1, and 2? This is complicated. I want to be able to fork a child action, and communicate

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

Getting the file descriptor from a handle, without closing it

2011-10-01 Thread Volker Wysk
Hello! I need to get the file descriptors of some handles, but the handles should not be modified. They should not be closed by the operation. I guess, that the handle gets closed for a reason. But I'm using the revealed file descriptors in a way which should pose no problems for the integrity

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

2011-10-01 Thread Volker Wysk
On Saturday 01 October 2011 08:30:40 Volker Wysk wrote: If anyone can point out to me, how this non-blocking handleToFd function should be made, I would be grateful. This should be non-CLOSING handleToFd function. Sorry. Volker ___

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

2011-10-01 Thread Bas van Dijk
On 1 October 2011 08:30, Volker Wysk p...@volker-wysk.de wrote: 1. data FD = FD {  fdFD :: {-# UNPACK #-} !CInt,  fdIsNonBlocking :: {-# UNPACK #-} !Int  } What is that exclamation mark? That's a strictness annotation and is haskell98/2010: