I am developing a FUSE driver, and when I run it as a daemon (without the -f or -d flags), all https requests made using libcurl fail. I was able to reproduce the error by executing the https request, expanding and returning the parent process, and then making the second request from the new process. If I delete the call forkor make an http request, there are no errors.
I am making an official bug report right now, but does anyone know how I can make it work?
Here is my code and output (logfile):
Note: if you run my program, pipe to / dev / null, since libcurl sends the accepted buffer to stdout by default.
#include <curl/curl.h>
#include <string>
#include <unistd.h>
#include <iostream>
using namespace std;
void log(string str)
{
static const char logfile[] = "/home/austin/megalog";
FILE *f = fopen(logfile, "a");
fwrite(str.data(), str.size(), 1, f);
fclose(f);
cout << str;
}
int main(int argc, char *argv[])
{
string url = "https://www.google.com/";
char errBuf[1024];
CURLcode err;
curl_global_init(CURL_GLOBAL_DEFAULT);
CURL *handle = curl_easy_init();
curl_easy_setopt(handle, CURLOPT_URL, url.c_str());
curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, errBuf);
if ((err = curl_easy_perform(handle)))
{
log("first request failed\n");
return 1;
}
curl_easy_cleanup(handle);
if(fork())
return 0;
handle = curl_easy_init();
curl_easy_setopt(handle, CURLOPT_URL, url.c_str());
curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, errBuf);
if ((err = curl_easy_perform(handle)))
{
log(string("curl error while sending: (") + to_string(err) + ") " + curl_easy_strerror(err) + "\n");
log(errBuf);
}
else
log("no error\n");
return 0;
}
... and conclusion:
$ g++ -std=c++11 main.cpp -lcurl
$ rm -f log
$ ./a.out > /dev/null
$ cat log
curl error while sending: (35) SSL connect error
A PKCS
I am using (latest) version of libcurl 7.29.0 (latest version) openssl version 1.0.1e and I am running Fedora 18 with kernel version 3.7.4.