Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interfacing with the code which calls select()

I'm writing a Haskell binding to some the library and there is a function void foo(), which calls select() inside. When i call this function from Haskell, that select() call starts to constantly return EINTR. This confuses library code and it starts looping forever.

In the #haskell IRC channel i've been told to run foo() from a bound thread. I've used runInBoundThread for this and now everything seems to work. But in some rare cases i'm getting Alarm clock message in the console (Ok, i've found it means that app catches SIGALRM).

I'm not sure it's proper way to handle this problem and i don't want to depend on Control.Concurrency. What should i do?

like image 807
arrowd Avatar asked Oct 21 '22 21:10

arrowd


1 Answers

The cause of SIGALRM was GHC's runtime using old codepath for managing timer stuff. This old codepath was turning on because GHC's configure script had sort of linuxism in its check for create_timer() function. Fixing it made GHC use the same mechanism that is used on all platforms, and eliminated the error in question.

Relevant Phabricator Diff: https://phabricator.haskell.org/D831

like image 179
arrowd Avatar answered Oct 27 '22 17:10

arrowd