fix some semaphore wait semantics (race condition deadlock and error checking)
[musl] / src / thread / clone.c