Safer creation of memcached PID file.

This change avoids a race condition where another application (e.g., testapp)
can read the memcached pid file after memcached opens it, but before
memcached writes the pid. It now writes the pid into a temporary file and then
renames that file to the correct pid file name. This way the pid file can not
exist without containing the correct value.