xref: /curl/docs/libcurl/opts/CURLOPT_NOSIGNAL.md (revision f81f351b)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_NOSIGNAL
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_TIMEOUT (3)
9Protocol:
10  - All
11Added-in: 7.10
12---
13
14# NAME
15
16CURLOPT_NOSIGNAL - skip all signal handling
17
18# SYNOPSIS
19
20~~~c
21#include <curl/curl.h>
22
23CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NOSIGNAL, long onoff);
24~~~
25
26# DESCRIPTION
27
28If *onoff* is 1, libcurl uses no functions that install signal handlers or
29any functions that cause signals to be sent to the process. This option is
30here to allow multi-threaded Unix applications to still set/use all timeout
31options etc, without risking getting signals.
32
33If this option is set and libcurl has been built with the standard name
34resolver, timeouts cannot occur while the name resolve takes place. Consider
35building libcurl with the c-ares or threaded resolver backends to enable
36asynchronous DNS lookups, to enable timeouts for name resolves without the use
37of signals.
38
39Setting CURLOPT_NOSIGNAL(3) to 1 makes libcurl NOT ask the system to
40ignore SIGPIPE signals, which otherwise are sent by the system when trying to
41send data to a socket which is closed in the other end. libcurl makes an
42effort to never cause such SIGPIPE signals to trigger, but some operating
43systems have no way to avoid them and even on those that have there are some
44corner cases when they may still happen, contrary to our desire.
45
46# DEFAULT
47
480
49
50# %PROTOCOLS%
51
52# EXAMPLE
53
54~~~c
55int 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
75Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
76