cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: [PATCH] Callback to abort libcurl when receiving a signal

From: Alessandro Vesely <vesely_at_tana.it>
Date: Thu, 06 Mar 2008 12:39:44 +0100

Hi,
pardon me if I jump into this thread, but

Pierre Ynard wrote:
>> Once that said and taking in account that the network call will be
>> retried upon EINTR, you could still want it to fail for some very
>> specific signal, lets say SIGTERM, how would you do it ?
>
> I wouldn't really handle any specific signal in libcurl itself, because
> it is too much binding to some specific behavior and could not be very
> portable.

Let me just note that this is an area where we should expect
portability issues. In facts, the X/Open System Interfaces (XSI)
specifies stuff like:

[sigaction]
SA_RESTART
     [XSI] [Option Start] This flag affects the behavior of
interruptible functions; that is, those specified to fail with errno
set to [EINTR]. If set, and a function specified as interruptible is
interrupted by this signal, the function shall restart and shall not
fail with [EINTR] unless otherwise specified. If the flag is not set,
interruptible functions interrupted by this signal shall fail with
errno set to [EINTR]. [Option End]

and

[pselect]
[EINTR]
     The function was interrupted before any of the selected events
occurred and before the timeout interval expired.

     [XSI] [Option Start] If SA_RESTART has been set for the
interrupting signal, it is implementation-defined whether the function
restarts or returns with [EINTR]. [Option End]

Thus, for the libcurl portability, we should handle specific
deviations adequately. For example, see this five years old Perl thread:

Re: POSIX::sigaction vs. safe signals
http://www.nntp.perl.org/group/perl.perl5.porters/2003/07/msg77940.html
Received on 2008-03-06