[Haskell-cafe] Re: sendfile leaking descriptors on Linux?
Bardur Arantsson
spam at scientician.net
Sat Feb 6 03:16:35 EST 2010
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...
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...
Cheers,
More information about the Haskell-Cafe
mailing list