cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Asking for the reversion of the pselect() patch

From: Jamie Lokier <jamie_at_shareable.org>
Date: Sun, 11 Mar 2007 20:45:32 +0000

Daniel Stenberg wrote:
> >I have a very strong feeling against the patch which has been commited
> >relative to the use of pselect().
>
> Ok, I'll revert that change again to allow us to discuss and work on this
> topic more first.

As far as I know (and I have looked into it somewhat), the only
portable way to combine signals and select/poll, with no race hazard,
is to have the signal handler write to a pipe, and the pipe included
in the select/poll set.

(Even that doesn't work on Windows with Winsock 1 (select() doesn't
work with pipes there), but I'm not sure what "signal" means in that
environment anyway.)

Another technique is siglongjmp() from the signal handler, to outside
the select() call. But that is less portable, as it crashes some
systems.

If not using a pipe or siglongjmp, the next best thing is to use a
reasonably short timeout with every call select/poll, so the program
doesn't get stuck but may occasionally delay a short time. (A
variation, to reduce wakeup frequency, is to have the signal handler
call setitimer(), but that's really best avoided especially in a
library.)

-- Jamie
Received on 2007-03-11