1 /*
2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
3 * AUTHOR : William Roske
4 * CO-PILOT : Dave Fenner
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of version 2 of the GNU General Public License as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it would be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 *
14 * Further, this software is distributed without any warranty that it is
15 * free of the rightful claim of any third person regarding infringement
16 * or the like. Any license provided herein, whether implied or
17 * otherwise, applies only to this software file. Patent licenses, if
18 * any, provided herein do not apply to combinations of this program with
19 * other software, or any other product whatsoever.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 *
25 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
26 * Mountain View, CA 94043, or:
27 *
28 * http://www.sgi.com
29 *
30 * For further information regarding this notice, see:
31 *
32 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
33 *
34 */
35
36 #include <errno.h>
37 #include <string.h>
38 #include <signal.h>
39 #include <stdlib.h>
40 #include <sys/types.h>
41 #include <sys/wait.h>
42 #include "test.h"
43
44 static void setup(void);
45 static void cleanup(void);
46
47 char *TCID = "wait02";
48 int TST_TOTAL = 1;
49
50 static void wait_verify(void);
51
main(int ac,char ** av)52 int main(int ac, char **av)
53 {
54 int lc;
55
56 tst_parse_opts(ac, av, NULL, NULL);
57
58 setup();
59
60 for (lc = 0; TEST_LOOPING(lc); lc++) {
61 tst_count = 0;
62 wait_verify();
63 }
64
65 cleanup();
66 tst_exit();
67 }
68
setup(void)69 static void setup(void)
70 {
71 tst_sig(FORK, DEF_HANDLER, cleanup);
72
73 TEST_PAUSE;
74 }
75
wait_verify(void)76 static void wait_verify(void)
77 {
78 int fork_pid, status, exit_child = 1;
79
80 fork_pid = FORK_OR_VFORK();
81 if (fork_pid == -1) {
82 tst_brkm(TBROK | TERRNO, cleanup, "fork() Failure");
83 } else if (fork_pid == 0) {
84 sleep(1);
85 exit(exit_child);
86 }
87
88 TEST(wait(&status));
89
90 if (TEST_RETURN == -1) {
91 tst_resm(TFAIL | TTERRNO, "wait(1) Failed");
92 } else if (WIFEXITED(status) && WEXITSTATUS(status) == exit_child) {
93 tst_resm(TPASS, "wait(&status) returned %ld", TEST_RETURN);
94 } else {
95 tst_resm(TFAIL,
96 "wait(1) Failed, exit_child - 0x%x, status - 0x%x",
97 exit_child, status);
98 }
99 }
100
cleanup(void)101 static void cleanup(void)
102 {
103 }
104