1 /******************************************************************************
2 * Copyright (c) Crackerjack Project., 2007 *
3 * Ported to LTP by Manas Kumar Nayak <maknayak@in.ibm.com> *
4 * Copyright (C) 2015 Cyril Hrubis <chrubis@suse.cz> *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See *
14 * the GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software Foundation, *
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 * *
20 ******************************************************************************/
21
22 #include <stdio.h>
23 #include <errno.h>
24 #include <linux/unistd.h>
25 #include <sys/wait.h>
26
27 #include "test.h"
28 #include "safe_macros.h"
29 #include "lapi/syscalls.h"
30
31 char *TCID = "exit_group01";
32 int testno;
33 int TST_TOTAL = 1;
34
verify_exit_group(void)35 static void verify_exit_group(void)
36 {
37 pid_t cpid, w;
38 int status;
39
40 cpid = fork();
41 if (cpid == -1)
42 tst_brkm(TFAIL | TERRNO, NULL, "fork failed");
43
44 if (cpid == 0) {
45 TEST(ltp_syscall(__NR_exit_group, 4));
46 } else {
47 w = SAFE_WAIT(NULL, &status);
48
49 if (WIFEXITED(status) && (WEXITSTATUS(status) == 4)) {
50 tst_resm(TPASS, "exit_group() succeeded");
51 } else {
52 tst_resm(TFAIL | TERRNO,
53 "exit_group() failed (wait status = %d)", w);
54 }
55 }
56 }
57
main(int ac,char ** av)58 int main(int ac, char **av)
59 {
60 int lc;
61
62 tst_parse_opts(ac, av, NULL, NULL);
63
64 for (lc = 0; TEST_LOOPING(lc); lc++)
65 verify_exit_group();
66
67 tst_exit();
68 }
69