curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: curl crashes when internet switched off

From: Daniel Stenberg via curl-library <curl-library_at_cool.haxx.se>
Date: Wed, 4 Sep 2019 15:45:38 +0200 (CEST)

On Wed, 4 Sep 2019, Salman Ahmed wrote:

Please stop top-posting. It makes it really hard to follow this
discussion/thread.

> I updated my libcurl to 7.65.3 and at the same time I found out that the 3rd
> party sdk i am using does use curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1).
> After I set that to "0" my program didn't terminate when wifi was switched
> off.

Then you could probably achieve the same result with the older version as
well.

> But from the brief reading on google,

Don't read on google. Read the genuine docs on the curl site.

> it seems that CURLOPT_NOSIGNAL should be set to 1 for multithreaded
> applications like mine. Is there a way to keep CURLOPT_NOSIGNAL = 1 and
> handle the broken SIGPIPE problem I am getting originally?

It depends on what you want to do.

The SIGPIPE signal here originates from OpenSSL (when it tries to use the
socket after the connection has closed). The only way to prevent that from
happening in libcurl is for libcurl to switch off the signal on entry and
switch it on again on exit. It does this if CURLOPT_NOSIGNAL is set to 1.

The sighandler is however global for your application so if you use libcurl
from multiple threads within that application libcurl will switch that state
on/off in a racy manner and you don't really know how it'll handle the signal
if/when it arrives.

You're then better off adding a single global SIGPIPE ignore yourself and tell
curl to hands off anything that has to do with signals.

-- 
  / daniel.haxx.se | Get the best commercial curl support there is - from me
                   | Private help, bug fixes, support, ports, new features
                   | https://www.wolfssl.com/contact/
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2019-09-04