fix race condition in pthread_kill