Replaced unsafe pthread calls with async-safe equivalents.

KSCrash will no longer deadlock from crashes inside a pthread call.