
On Sat, Feb 06, 2010 at 09:16:35AM +0100, Bardur Arantsson wrote:
Brandon S. Allbery KF8NH wrote:
On Feb 5, 2010, at 02:56 , Bardur Arantsson wrote: [--snip--]
"Broken pipe" is normally handled as a signal, and is only mapped to an error if SIGPIPE is set to SIG_IGN. I can well imagine that the SIGPIPE signal handler isn't closing resources properly; a workaround would be to use the System.Posix.Signals API to ignore SIGPIPE, but I don't know if that would work as a general solution (it would depend on what other uses of pipes/sockets exist).
It was a good idea, but it doesn't seem to help to add
installHandler sigPIPE Ignore (Just fullSignalSet)
to the main function. (Given the package name I assume System.Posix.Signals works similarly to regular old signals, i.e. globally per-process.)
This is really starting to drive me round the bend...
Have you seen GHC ticket #1619? http://hackage.haskell.org/trac/ghc/ticket/1619
One further thing I've noticed: When compiling on my 64-bit machine, ghc issues the following warnings:
Linux.hsc:41: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long unsigned int’ Linux.hsc:45: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long unsigned int’ Linux.hsc:45: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long unsigned int’ Linux.hsc:45: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long unsigned int’
Those lines are:
39: -- max num of bytes in one send 40: maxBytes :: Int64 41: maxBytes = fromIntegral (maxBound :: (#type ssize_t))
and
44: foreign import ccall unsafe "sendfile64" c_sendfile 45: :: Fd -> Fd -> Ptr (#type off_t) -> (#type size_t) -> IO (#type ssize_t)
This looks like a typical 32/64-bit problem, but normally I would expect any real run-time problems caused by a problematic conversion in the FFI to crash the whole process. Maybe I'm wrong about this...
To convert those '#' constants, hsc2hs preprocessor constructs a C file things like 'printf("%d", sizeof(ssize_t))' to use the system's C compiler and avoid having the encode the ABI of every platform (to be able to know the memory layout of the structures). So that message comes from that C file, not from your Haskell one. At runtime it really doesn't matter. -- Felipe.