CURLOPT_NOSIGNAL.md (1942B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_NOSIGNAL 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_TIMEOUT (3) 9 Protocol: 10 - All 11 Added-in: 7.10 12 --- 13 14 # NAME 15 16 CURLOPT_NOSIGNAL - skip all signal handling 17 18 # SYNOPSIS 19 20 ~~~c 21 #include <curl/curl.h> 22 23 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NOSIGNAL, long onoff); 24 ~~~ 25 26 # DESCRIPTION 27 28 If *onoff* is 1, libcurl uses no functions that install signal handlers or 29 any functions that cause signals to be sent to the process. This option is 30 here to allow multi-threaded Unix applications to still set/use all timeout 31 options etc, without risking getting signals. 32 33 If this option is set and libcurl has been built with the standard name 34 resolver, timeouts cannot occur while the name resolve takes place. Consider 35 building libcurl with the c-ares or threaded resolver backends to enable 36 asynchronous DNS lookups, to enable timeouts for name resolves without the use 37 of signals. 38 39 Setting CURLOPT_NOSIGNAL(3) to 1 makes libcurl NOT ask the system to 40 ignore SIGPIPE signals, which otherwise are sent by the system when trying to 41 send data to a socket which is closed in the other end. libcurl makes an 42 effort to never cause such SIGPIPE signals to trigger, but some operating 43 systems have no way to avoid them and even on those that have there are some 44 corner cases when they may still happen, contrary to our desire. 45 46 # DEFAULT 47 48 0 49 50 # %PROTOCOLS% 51 52 # EXAMPLE 53 54 ~~~c 55 int main(void) 56 { 57 CURL *curl = curl_easy_init(); 58 if(curl) { 59 CURLcode res; 60 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); 61 62 curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1L); 63 64 res = curl_easy_perform(curl); 65 66 curl_easy_cleanup(curl); 67 } 68 } 69 ~~~ 70 71 # %AVAILABILITY% 72 73 # RETURN VALUE 74 75 curl_easy_setopt(3) returns a CURLcode indicating success or error. 76 77 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 78 libcurl-errors(3).