@cryptotaxi247 / netdata-1 / commits / f1394e071

Adjust curl options when submitting events (#21696)

Discard curl response / disable signal-based timeouts

Stelios Fragkakis committed Feb 2, 2026 at 22:59 UTC f1394e0714bae601e933ef02742fc55bc3c9f71d
1 file changed +17
src/daemon/status-file.c
+17
@@ -924,6 +924,14 @@ static const char *agent_health(DAEMON_STATUS_FILE *ds) {
924 return "healthy-recovered";
925 }
926
927 +// Callback to discard curl response data.
928 +// Without this, curl writes to stdout which can crash on Windows when running as a service.
929 +static size_t post_status_file_discard_response(void *ptr, size_t size, size_t nmemb, void *userdata) {
930 + (void)ptr;
931 + (void)userdata;
932 + return size * nmemb;
933 +}
934 +
935 static void post_status_file(struct post_status_file_thread_data *d) {
936 daemon_status_file_startup_step("startup(crash reports json)");
937
@@ -953,6 +961,15 @@ static void post_status_file(struct post_status_file_thread_data *d) {
961 curl_easy_setopt(curl, CURLOPT_URL, "https://agent-events.netdata.cloud/agent-events");
962 curl_easy_setopt(curl, CURLOPT_POST, 1L);
963 curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json_data);
964 +
965 + // Discard response data - without this curl writes to stdout which can crash
966 + // on Windows when running as a service or without a console
967 + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, post_status_file_discard_response);
968 + curl_easy_setopt(curl, CURLOPT_WRITEDATA, NULL);
969 +
970 + // Prevent signal-based timeouts which can cause issues on Windows/MSYS2
971 + curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1L);
972 +
973 struct curl_slist *headers = NULL;
974 headers = curl_slist_append(headers, "Content-Type: application/json");
975 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);