1*880fe46bSchristos /* $NetBSD: sigqueue.c,v 1.2 2011/01/10 16:42:36 christos Exp $ */
2c5aa3a87Schristos
3c5aa3a87Schristos /*-
4c5aa3a87Schristos * Copyright (c) 2011 The NetBSD Foundation, Inc.
5c5aa3a87Schristos * All rights reserved.
6c5aa3a87Schristos *
7c5aa3a87Schristos * This code is derived from software contributed to The NetBSD Foundation
8c5aa3a87Schristos * by Christos Zoulas.
9c5aa3a87Schristos *
10c5aa3a87Schristos * Redistribution and use in source and binary forms, with or without
11c5aa3a87Schristos * modification, are permitted provided that the following conditions
12c5aa3a87Schristos * are met:
13c5aa3a87Schristos * 1. Redistributions of source code must retain the above copyright
14c5aa3a87Schristos * notice, this list of conditions and the following disclaimer.
15c5aa3a87Schristos * 2. Redistributions in binary form must reproduce the above copyright
16c5aa3a87Schristos * notice, this list of conditions and the following disclaimer in the
17c5aa3a87Schristos * documentation and/or other materials provided with the distribution.
18c5aa3a87Schristos *
19c5aa3a87Schristos * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20c5aa3a87Schristos * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21c5aa3a87Schristos * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22c5aa3a87Schristos * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23c5aa3a87Schristos * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24c5aa3a87Schristos * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25c5aa3a87Schristos * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26c5aa3a87Schristos * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27c5aa3a87Schristos * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28c5aa3a87Schristos * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29c5aa3a87Schristos * POSSIBILITY OF SUCH DAMAGE.
30c5aa3a87Schristos */
31c5aa3a87Schristos #include <sys/cdefs.h>
32c5aa3a87Schristos #if defined(LIBC_SCCS) && !defined(lint)
33*880fe46bSchristos __RCSID("$NetBSD: sigqueue.c,v 1.2 2011/01/10 16:42:36 christos Exp $");
34c5aa3a87Schristos #endif /* LIBC_SCCS and not lint */
35c5aa3a87Schristos
36c5aa3a87Schristos #include "namespace.h"
37c5aa3a87Schristos #include <sys/types.h>
38c5aa3a87Schristos #include <sys/syscall.h>
39c5aa3a87Schristos #include <string.h>
40c5aa3a87Schristos #include <signal.h>
41c5aa3a87Schristos #include <unistd.h>
42c5aa3a87Schristos
43c5aa3a87Schristos /*
44c5aa3a87Schristos * This is wrapper around sigqueueinfo(2), providing a sigqueue()
45c5aa3a87Schristos * implementation for userland.
46c5aa3a87Schristos */
47c5aa3a87Schristos int
sigqueue(pid_t pid,int signo,const union sigval value)48c5aa3a87Schristos sigqueue(pid_t pid, int signo, const union sigval value)
49c5aa3a87Schristos {
50c5aa3a87Schristos siginfo_t info;
51c5aa3a87Schristos
52c5aa3a87Schristos (void)memset(&info, 0, sizeof(info));
53c5aa3a87Schristos
54c5aa3a87Schristos info.si_signo = signo;
55c5aa3a87Schristos info.si_code = SI_QUEUE;
56c5aa3a87Schristos info.si_pid = getpid();
57c5aa3a87Schristos info.si_uid = geteuid();
58c5aa3a87Schristos info.si_value = value;
59c5aa3a87Schristos
60c5aa3a87Schristos return sigqueueinfo(pid, &info);
61c5aa3a87Schristos }
62