Re: is Event the best event loop module?
[email protected] (Nick Ing-Simmons)
| Newsgroups | perl.loop |
|---|---|
| Message-ID | <[email protected]> |
Danny Faught <[email protected]> writes: >Uri Guttman wrote: >> are you doing your own signal handling in perl? if so, you should switch >> to event.pm. perl's signal handling is well known to be unsafe. > >I'm putting together some code samples to explain how event loops work, >but for any serious even-driven work, I'd use one of the available >libraries. FWIW, the slides will be on my web site some time tomorrow. > >> the way to handle that properly is to check for any pending signals >> before you enter the select call (while blocking any from coming in) and >> then checking after the select returns. this can only be done correctly >> in C. > >There's no way in perl or C that I know of to atomically set a signal >mask and enter a select call. I've seen rumors of a pselect library >call available on some systems that can do this. A sigprocmask call >followed by a select call has a race condition, because a signal can >come in between the two statements. How do you solve this in C? I've >seen a klugey solution that requires a setjmp/longjmp. The way I have seen this fixed is to have signal handler write() to a pipe that is in the select() list rather than just set a flag. -- Nick Ing-Simmons http://www.ni-s.u-net.com/