Re: [Haskell-cafe] syscall, sigpause and EINTR on Mac OSX
Quoth Joel Reymont <joelr1@gmail.com>: ... | My program is currently stuck here. The man pages say that sigpause | will only terminate by being interrupted and EINTR will be the errno. | EINTR is signal 2, the same one that I'm trapping and the one sent | when ^C is pressed. I sure haven't been able to follow all of the ensuing discussion on this, but in case it helps -- EINTR is not a signal, it's an error status from a function that was interrupted by a signal. Just going on this error, the signal may have been SIGINT - or any other signal, such as for example SIGALRM, which could be generated by a timer function (see alarm, setitimer), or SIGCHLD, which could be generated on exit of a child process under certain circumstances. Etc. Obviously the use of signals in this way (timers, for example) has the potential to make your application unsound. It's particularly insidious when it occurs in library functions. Now if you actually have observed that your SIGINT handler was entered at this point, then please ignore me. Donn Cave, donn@drizzle.com
On Dec 11, 2005, at 8:35 PM, Donn Cave wrote:
Now if you actually have observed that your SIGINT handler was entered at this point, then please ignore me.
Yes, I have observed my SIGINT handler being triggered out of nowhere. Since I'm printing the signal# in the handler I actually know that it was SIGINT. Since we are dealing with computers and magic is out of the question I can only think of Mac OSX sending SIGINT when the program went over some resource limit. Probably not, though, as I left it running in gdb, went to sleep, woke up about an hour and a half later to see that the program stopped after about 15 minutes and dropped into the debugger with a SIGINT. gdb has nothing to do with this as I saw it happen outside of the debugger. For the record, I often ^C the program as it's supposed to run forever, with poker bots just sitting their, playing and grabbing more money when they run out of it. The C++/Windows server is not very good at handling abrupt disconnects so it helps when certain commands are sent to it before a client disconnects. This is what I do in the SIGINT handler by placing QUIT events into each thread's mailbox. I sorely miss the Erlang REPL here, btw, with its ability to send messages to various running processes and such. I'm also thinking of designing a "process" class in Haskell to emulate Erlang processes, together with the associated infrastructure to keep track of processes, their message counts, etc. I do not want to recode my stuff in Erlang as Erlang FFI makes me grind my teeth and I would need to use it to get to the OpenSSL BIO API and for ZLib. I also invested over two months into the Haskell project by now and it's 95% done. Joel -- http://wagerlabs.com/
participants (2)
-
Donn Cave -
Joel Reymont