• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <signal.h>
38 #include <sys/wait.h>
39 #include <string.h>
40 #include <stdlib.h>
41 #include "test.h"
42 
43 void setup();
44 void cleanup();
45 
46 char *TCID = "setpgrp01";
47 int TST_TOTAL = 1;
48 
main(int ac,char ** av)49 int main(int ac, char **av)
50 {
51 	int lc;
52 
53 	tst_parse_opts(ac, av, NULL, NULL);
54 
55 	setup();
56 
57 	for (lc = 0; TEST_LOOPING(lc); lc++) {
58 
59 		tst_count = 0;
60 
61 		/*
62 		 * TEST CASE:
63 		 *  Call the setpgrp system call
64 		 */
65 		TEST(setpgrp());
66 
67 		if (TEST_RETURN != 0) {
68 			tst_resm(TFAIL,
69 				 "setpgrp -  Call the setpgrp system call failed, errno=%d : %s",
70 				 TEST_ERRNO, strerror(TEST_ERRNO));
71 		} else {
72 			tst_resm(TPASS,
73 				 "setpgrp -  Call the setpgrp system call returned %ld",
74 				 TEST_RETURN);
75 		}
76 
77 	}
78 
79 	cleanup();
80 	tst_exit();
81 }
82 
setup(void)83 void setup(void)
84 {
85 	int pid, status;
86 
87 	tst_sig(FORK, DEF_HANDLER, cleanup);
88 
89 	TEST_PAUSE;
90 
91 	/*
92 	 * Make sure current process is NOT a session or pgrp leader
93 	 */
94 	if (getpgrp() == getpid()) {
95 		if ((pid = FORK_OR_VFORK()) == -1) {
96 			tst_brkm(TBROK, cleanup,
97 				 "fork() in setup() failed - errno %d", errno);
98 		}
99 
100 		if (pid != 0) {	/* parent - sits and waits */
101 			wait(&status);
102 			exit(WEXITSTATUS(status));
103 		}
104 
105 	}
106 }
107 
cleanup(void)108 void cleanup(void)
109 {
110 }
111