xref: /freebsd/tests/sys/kern/pdeathsig_helper.c (revision 1d386b48a555f61cb7325543adbbb5c3f3407a66)
1b9408863SKonstantin Belousov /*-
2b9408863SKonstantin Belousov  * Copyright (c) 2018 Thomas Munro
3b9408863SKonstantin Belousov  * All rights reserved.
4b9408863SKonstantin Belousov  *
5b9408863SKonstantin Belousov  * Redistribution and use in source and binary forms, with or without
6b9408863SKonstantin Belousov  * modification, are permitted provided that the following conditions
7b9408863SKonstantin Belousov  * are met:
8b9408863SKonstantin Belousov  * 1. Redistributions of source code must retain the above copyright
9b9408863SKonstantin Belousov  *    notice, this list of conditions and the following disclaimer.
10b9408863SKonstantin Belousov  * 2. Redistributions in binary form must reproduce the above copyright
11b9408863SKonstantin Belousov  *    notice, this list of conditions and the following disclaimer in the
12b9408863SKonstantin Belousov  *    documentation and/or other materials provided with the distribution.
13b9408863SKonstantin Belousov  *
14b9408863SKonstantin Belousov  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15b9408863SKonstantin Belousov  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16b9408863SKonstantin Belousov  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17b9408863SKonstantin Belousov  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18b9408863SKonstantin Belousov  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19b9408863SKonstantin Belousov  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20b9408863SKonstantin Belousov  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21b9408863SKonstantin Belousov  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22b9408863SKonstantin Belousov  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23b9408863SKonstantin Belousov  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24b9408863SKonstantin Belousov  * SUCH DAMAGE.
25b9408863SKonstantin Belousov  */
26b9408863SKonstantin Belousov 
27b9408863SKonstantin Belousov #include <sys/cdefs.h>
28b9408863SKonstantin Belousov #include <assert.h>
29b9408863SKonstantin Belousov #include <signal.h>
30b9408863SKonstantin Belousov #include <sys/procctl.h>
31b9408863SKonstantin Belousov 
main(int argc,char ** argv)32b9408863SKonstantin Belousov int main(int argc, char **argv)
33b9408863SKonstantin Belousov {
34b9408863SKonstantin Belousov         int signum;
35b9408863SKonstantin Belousov         int rc;
36b9408863SKonstantin Belousov 
37b9408863SKonstantin Belousov 	/*
38b9408863SKonstantin Belousov 	 * This program is executed by the pdeathsig test
39*1302eea7SKonstantin Belousov 	 * to check if the PROC_PDEATHSIG_CTL setting was
40b9408863SKonstantin Belousov 	 * inherited.
41b9408863SKonstantin Belousov 	 */
42b9408863SKonstantin Belousov         signum = 0xdeadbeef;
43*1302eea7SKonstantin Belousov         rc = procctl(P_PID, 0, PROC_PDEATHSIG_STATUS, &signum);
44b9408863SKonstantin Belousov         assert(rc == 0);
45b9408863SKonstantin Belousov         assert(signum == SIGINFO);
46b9408863SKonstantin Belousov 
47b9408863SKonstantin Belousov         return 0;
48b9408863SKonstantin Belousov }
49