Change double-fork to use waitpid() instead of wait() to prevent
forks from multiple threads getting mixed in wait().