[Haskell-cafe] Re: openFd under -threaded gets interrupted

Mitar mmitar at gmail.com
Fri Dec 18 01:17:46 EST 2009


Hi!

On Wed, Dec 16, 2009 at 3:18 PM, Mitar <mmitar at gmail.com> wrote:
> fd <- openFd device ReadWrite Nothing OpenFileFlags { append = False,
> noctty = True, exclusive = False, nonBlock = True, trunc = False }

OK. After some testing I have discovered that the problem is only with
/dev/rfcomm0 as a device, that is with Bluetooth serial connection.
The problem is that rfcomm Linux kernel code contains:

if (signal_pending(current)) {
    err = -EINTR;
    break;
}

So if during open call some signal comes it returns EINTR. As it has
to open a connection to a Bluetooth device opening a /dev/rfcomm0 file
requires some time and during that time obviously there is some signal
sent by GHC with -threaded option which is not sent without it.

So please tell me what is the difference between open with and without
-threaded option in GHC as I would like to make a simple C test case.

Also is there any workaround possible in Haskell/GHC? For example
making time while openFd is in progress without interrupts?

I have found very similar bug reported here:

https://bugzilla.redhat.com/show_bug.cgi?id=161314

but code from the patch does not seem to be included in official
kernel source code (but it is also a long time ago so many things have
probably changed). But the workaround there is working also here. If I
open /dev/rfcomm0 with some other program (so that Bluetooth
connection is made) before I run Haskell program then it works in both
cases, with or without -threaded option. Of course this is not really
useful workaround in my case, I would like to make a stand-alone
Haskell program.

So please help me solve this problem.

> But without -threaded it works flawlessly. I am using Linux 2.6.30
> amd64, GHC 6.10.4. It was the same with 6.8.

I have also tested it on 6.12 and it is the same.


Mitar


More information about the Haskell-Cafe mailing list