openFd under -threaded gets interrupted

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

openFd under -threaded gets interrupted

Mitar
Hi!

I am using such code:

fd <- openFd device ReadWrite Nothing OpenFileFlags { append = False,
noctty = True, exclusive = False, nonBlock = True, trunc = False }

And if I compile my program with -threaded option I always get such error:

interrupted (Interrupted system call)

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.

Why is this? Is there any workaround? Does it work in 6.12?


Mitar
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: openFd under -threaded gets interrupted

Mitar
Hi!

On Wed, Dec 16, 2009 at 3:18 PM, Mitar <[hidden email]> 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
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe