Erro de libCurl SSL após fork ()

Estou desenvolvendo um driver FUSE e quando eu o executo como um daemon (sem os sinalizadores -f ou -d) todos os requisições https feitas através do libcurl falham. Consegui reproduzir o erro fazendo uma solicitação https, bifurcando e retornando o processo pai e, em seguida, fazendo uma segunda solicitação do novo processo. Se eu remover ofork ligue ou faça uma solicitação http, não há erros.

Estou fazendo um relatório de bug oficial agora, mas alguém sabe como posso fazer isso funcionar?

Aqui está o meu código e a saída (logfile):

Nota: se você executar meu programa, canalize para / dev / null porque libcurl envia o buffer recebido para stdout por padrão.

#include <curl/curl.h>
#include <string>
#include <unistd.h>
#include <iostream>

using namespace std;

void log(string str)
{   //TODO: remove
    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;
}

... e a saída:

$ 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 #11 module returned CKR_DEVICE_ERROR, indicating that a problem has occurred with the token or slot.

Eu estou usando (o mais recente) libcurl versão 7.29.0, (o mais recente) openssl versão 1.0.1e, e eu estou rodando o Fedora 18 com a versão 3.7.4 do kernel.

questionAnswers(1)

yourAnswerToTheQuestion