cURL / Mailing Lists / curl-library / Single Mail


Re: SSL error after fork()

From: Nathan Rosenblum <>
Date: Sun, 17 Mar 2013 16:23:17 -0700

> I'm getting an SSL error in the child process after calling fork(). I made a
> short program that can reproduce it. Basically, if I make an https request,
> call fork and return the parent process, and then make a second https
> request, curl_easy_perform returns 35.

I haven't looked deeply into your specific problem, but in general you
should be very leery of calling fork(2) without a matching exec(2),
especially if you are using libraries or frameworks whose internals
you are not intimately familiar with & which you have initialized or
used in the parent process. The fork man page for your particular
platform should have a list of some (possibly not all) of the ways
that the child process is not exactly the same as the parent process.
If any of your libraries are starting threads, doing non-trivial
signal manipulation, setting timers, etc, you are in for a world of

You noted in your stackoverflow question that this arose in the
context of fuse, which as you note uses the daemon(2) call when you
don't pass a foreground fuseArg. Since daemon basically just forks,
you should be extremely careful to do the absolute minimum of work
before calling fuse_main.

Good luck!


(*) This applies doubly on OSX, where among other things Mach ports
(used for IPC) are closed across a fork.
List admin:
Received on 2013-03-18