headers/bsd: Add sys/queue.h.
[haiku.git] / src / system / libroot / posix / signal / sigqueue.cpp
blob8ad1a1ff3855f7484780009d92d63d60cc28d331
1 /*
2 * Copyright 2011, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
7 #include <signal.h>
9 #include <errno.h>
11 #include <syscall_utils.h>
13 #include <errno_private.h>
14 #include <signal_defs.h>
15 #include <syscalls.h>
18 int
19 sigqueue(pid_t pid, int signal, const union sigval userValue)
21 if (signal < 0)
22 RETURN_AND_SET_ERRNO(EINVAL);
24 if (pid <= 0)
25 RETURN_AND_SET_ERRNO(ESRCH);
27 status_t error = _kern_send_signal(pid, signal, &userValue,
28 SIGNAL_FLAG_QUEUING_REQUIRED);
29 if (error != B_OK) {
30 // translate B_BAD_THREAD_ID/B_BAD_TEAM_ID to ESRCH
31 if (error == B_BAD_THREAD_ID || error == B_BAD_TEAM_ID)
32 error = ESRCH;
35 RETURN_AND_SET_ERRNO(error);