Use _exit, not std::exit, to exit parent after daemonizing

This is rather pedantic, but to ensure a completely transparent
replacement of the parent, we need to use _exit.  Otherwise atexit
handlers and destructors could be called twice: once in the parent and
again in the child.
Add missing #include
Makefile: don't compile with -ansi
Makefile: avoid use of non-standard $^
Fix OpenSSL thread id callback on non-Linux systems

On FreeBSD, pthread_t is not implicitly castable to an unsigned
long (it's a pointer, so we can reinterpret_cast to an unsigned
long).