• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) Wipro Technologies Ltd, 2002.  All Rights Reserved.
4  *
5  * This is a Phase I test for the prctl(2) system call.
6  * It is intended to provide a limited exposure of the system call.
7  */
8 
9 #include <errno.h>
10 #include <signal.h>
11 #include <sys/prctl.h>
12 
13 #include "tst_test.h"
14 
verify_prctl(void)15 static void verify_prctl(void)
16 {
17 	int get_sig = 0;
18 
19 	TEST(prctl(PR_SET_PDEATHSIG, SIGUSR2));
20 	if (TST_RET == -1) {
21 		tst_res(TFAIL | TTERRNO, "prctl(PR_SET_PDEATHSIG) failed");
22 		return;
23 	}
24 
25 	tst_res(TPASS, "prctl(PR_SET_PDEATHSIG) succeeded");
26 
27 	TEST(prctl(PR_GET_PDEATHSIG, &get_sig));
28 	if (TST_RET == -1) {
29 		tst_res(TFAIL | TTERRNO, "prctl(PR_GET_PDEATHSIG) failed");
30 		return;
31 	}
32 
33 	if (get_sig == SIGUSR2) {
34 		tst_res(TPASS,
35 			"prctl(PR_GET_PDEATHSIG) got expected death signal");
36 	} else {
37 		tst_res(TFAIL, "prctl(PR_GET_PDEATHSIG) got death signal %d, expected %d",
38 			get_sig, SIGUSR2);
39 	}
40 }
41 
42 static struct tst_test test = {
43 	.test_all = verify_prctl,
44 };
45