develooper Front page | perl.perl5.porters | Postings from June 2012

Re: [perl #93428] potential race condition when mixing signals and select()

Thread Previous
From:
Leon Timmermans
Date:
June 5, 2012 13:29
Subject:
Re: [perl #93428] potential race condition when mixing signals and select()
Message ID:
CAHhgV8jNKRPJV-Ky2zxKQVxAWTgvniFiAeezAXFUfaG=VjRT+g@mail.gmail.com
On Fri, Jun 1, 2012 at 12:00 PM, Nicholas Clark <nick@ccl4.org> wrote:
> On Sun, May 27, 2012 at 03:34:02PM -0700, Leon Timmermans via RT wrote:
>> On Fri Jan 13 08:39:09 2012, nicholas wrote:
>> > Gah, and I suspect it's really hard, if not impossible, to probe for
>> > that.
>> > hints files?
>>
>> To the contrary, it seems quite easy. Set a signal-handler (without the
>> SA_RESTART flag), block that signal, send it to the process and then do
>> a pselect unblocking that signal. If it's a real pselect, it will be
>> interrupted and thus return EINTR. If pselect is faked the signal will
>> arrive right after the sigprocmask (and thus before the select) so it
>> won't be interrupted.
>
> Nice trick. Who is writing the demo code? :-)

The trick is from POSIX::pselect's test suite and it seems to be
correct on all major platform :-)

Leon

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About