summaryrefslogtreecommitdiff
path: root/lib/libc/signal/pthread_kill.c
blob: d6855c0c4ce9b74aa0680aa0bf9cc3aec94090ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "asm/unistd_64.h" // for __NR_tkill
#include "errno.h"	   // for EINVAL

#include <asm-generic/signal.h> // for _NSIG
#include <syscall.h>		// for __syscall_2, syscall
#include <thread.h>		// for __thread_self

typedef struct __thread_self *pthread_t;

int pthread_kill(pthread_t thread, int sig)
{
	if (sig < 0 || sig > _NSIG) {
		return EINVAL;
	}

	if (thread->tid == 0) {
		return 0;
	}

	return syscall(tkill, thread->tid, sig);
}