1/*
2 * Copyright 2004-2006, Axel D��rfler, axeld@pinc-software.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5
6
7#include <errno.h>
8#include <signal.h>
9
10#include <OS.h>
11
12#include <errno_private.h>
13#include <syscalls.h>
14
15
16int
17kill(pid_t pid, int sig)
18{
19	status_t status;
20
21	if (sig < 0) {
22		__set_errno(EINVAL);
23		return -1;
24	}
25
26	status = _kern_send_signal(pid, sig, NULL, 0);
27	if (status != B_OK) {
28		// translate B_BAD_THREAD_ID/B_BAD_TEAM_ID to ESRCH
29		if (status == B_BAD_THREAD_ID || status == B_BAD_TEAM_ID)
30			status = ESRCH;
31
32		__set_errno(status);
33		return -1;
34	}
35
36	return 0;
37}
38