curl / Mailing Lists / curl-library / Single Mail


Re: Aborting curl request when SIGTERM received

From: Prashant Shubham via curl-library <>
Date: Wed, 3 Apr 2019 15:46:33 +0530

On 4/2/19, Dan Fandrich via curl-library <> wrote:
> On Tue, Apr 02, 2019 at 03:39:14PM +0530, Prashant Shubham via curl-library
> wrote:
>> If there is an ongoing curl request and the application receives
>> SIGTERM, is there a way curl can acknowledge and abort the request in
>> middle.
> The most reliable way to do this is probably to write a SIGTERM handler that
> sets a global flag, then check the flag from the CURLOPT_XFERINFOFUNCTION
> callback function and return non-zero when it's set. This will cause the
> transfer to be aborted and return CURLE_ABORTED_BY_CALLBACK.
> CURLOPT_XFERINFOFUNCTION is called fairly frequently even when nothing is
> happening so there won't be much of a delay before the signal is
> acknowledged.
> You can also check the flag in your read/write callback function to reduce
> the
> delay even further in the case of an ongoing transfer.
>>>> Dan
> -------------------------------------------------------------------
> Unsubscribe:
> Etiquette:

Thanks Dan, working as expected :)
Received on 2019-04-03