github.com/afumu/libc@v0.0.6/musl/src/thread/pthread_kill.c (about)

     1  #include "pthread_impl.h"
     2  #include "lock.h"
     3  
     4  int pthread_kill(pthread_t t, int sig)
     5  {
     6  	int r;
     7  	sigset_t set;
     8  	/* Block not just app signals, but internal ones too, since
     9  	 * pthread_kill is used to implement pthread_cancel, which
    10  	 * must be async-cancel-safe. */
    11  	__block_all_sigs(&set);
    12  	LOCK(t->killlock);
    13  	r = t->tid ? -__syscall(SYS_tkill, t->tid, sig)
    14  		: (sig+0U >= _NSIG ? EINVAL : 0);
    15  	UNLOCK(t->killlock);
    16  	__restore_sigs(&set);
    17  	return r;
    18  }