fix some semaphore wait semantics (race condition deadlock and error checking)
[musl] / crt / crt1.c