1*49cdfc7eSAndroid Build Coastguard Worker /*
2*49cdfc7eSAndroid Build Coastguard Worker *
3*49cdfc7eSAndroid Build Coastguard Worker * Copyright (c) International Business Machines Corp., 2001
4*49cdfc7eSAndroid Build Coastguard Worker *
5*49cdfc7eSAndroid Build Coastguard Worker * This program is free software; you can redistribute it and/or modify
6*49cdfc7eSAndroid Build Coastguard Worker * it under the terms of the GNU General Public License as published by
7*49cdfc7eSAndroid Build Coastguard Worker * the Free Software Foundation; either version 2 of the License, or
8*49cdfc7eSAndroid Build Coastguard Worker * (at your option) any later version.
9*49cdfc7eSAndroid Build Coastguard Worker *
10*49cdfc7eSAndroid Build Coastguard Worker * This program is distributed in the hope that it will be useful,
11*49cdfc7eSAndroid Build Coastguard Worker * but WITHOUT ANY WARRANTY; without even the implied warranty of
12*49cdfc7eSAndroid Build Coastguard Worker * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13*49cdfc7eSAndroid Build Coastguard Worker * the GNU General Public License for more details.
14*49cdfc7eSAndroid Build Coastguard Worker *
15*49cdfc7eSAndroid Build Coastguard Worker * You should have received a copy of the GNU General Public License
16*49cdfc7eSAndroid Build Coastguard Worker * along with this program; if not, write to the Free Software
17*49cdfc7eSAndroid Build Coastguard Worker * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18*49cdfc7eSAndroid Build Coastguard Worker */
19*49cdfc7eSAndroid Build Coastguard Worker
20*49cdfc7eSAndroid Build Coastguard Worker /*
21*49cdfc7eSAndroid Build Coastguard Worker * Testcase to check the basic functionality of the setrlimit system call.
22*49cdfc7eSAndroid Build Coastguard Worker * Use the different commands like RLIMIT_NOFILE, RLIMIT_CORE,
23*49cdfc7eSAndroid Build Coastguard Worker * RLIMIT_FSIZE, and, RLIMIT_NOFILE, and test for different test
24*49cdfc7eSAndroid Build Coastguard Worker * conditions.
25*49cdfc7eSAndroid Build Coastguard Worker *
26*49cdfc7eSAndroid Build Coastguard Worker * 07/2001 Ported by Wayne Boyer
27*49cdfc7eSAndroid Build Coastguard Worker */
28*49cdfc7eSAndroid Build Coastguard Worker
29*49cdfc7eSAndroid Build Coastguard Worker #include <sys/types.h>
30*49cdfc7eSAndroid Build Coastguard Worker #include <sys/resource.h>
31*49cdfc7eSAndroid Build Coastguard Worker #include <sys/stat.h>
32*49cdfc7eSAndroid Build Coastguard Worker #include <sys/time.h>
33*49cdfc7eSAndroid Build Coastguard Worker #include <sys/wait.h>
34*49cdfc7eSAndroid Build Coastguard Worker #include <errno.h>
35*49cdfc7eSAndroid Build Coastguard Worker #include <fcntl.h>
36*49cdfc7eSAndroid Build Coastguard Worker #include <stdlib.h>
37*49cdfc7eSAndroid Build Coastguard Worker #include <unistd.h>
38*49cdfc7eSAndroid Build Coastguard Worker #include "test.h"
39*49cdfc7eSAndroid Build Coastguard Worker #include "safe_macros.h"
40*49cdfc7eSAndroid Build Coastguard Worker
41*49cdfc7eSAndroid Build Coastguard Worker char *TCID = "setrlimit01";
42*49cdfc7eSAndroid Build Coastguard Worker int TST_TOTAL = 1;
43*49cdfc7eSAndroid Build Coastguard Worker
44*49cdfc7eSAndroid Build Coastguard Worker static void setup(void);
45*49cdfc7eSAndroid Build Coastguard Worker static void cleanup(void);
46*49cdfc7eSAndroid Build Coastguard Worker static void test1(void);
47*49cdfc7eSAndroid Build Coastguard Worker static void test2(void);
48*49cdfc7eSAndroid Build Coastguard Worker static void test3(void);
49*49cdfc7eSAndroid Build Coastguard Worker static void test4(void);
50*49cdfc7eSAndroid Build Coastguard Worker static void sighandler(int);
51*49cdfc7eSAndroid Build Coastguard Worker
52*49cdfc7eSAndroid Build Coastguard Worker static char filename[40] = "";
53*49cdfc7eSAndroid Build Coastguard Worker static struct rlimit save_rlim, rlim, rlim1;
54*49cdfc7eSAndroid Build Coastguard Worker static int nofiles, fd, bytes, i, status;
55*49cdfc7eSAndroid Build Coastguard Worker static char *buf = "abcdefghijklmnopqrstuvwxyz";
56*49cdfc7eSAndroid Build Coastguard Worker static pid_t pid;
57*49cdfc7eSAndroid Build Coastguard Worker
main(int ac,char ** av)58*49cdfc7eSAndroid Build Coastguard Worker int main(int ac, char **av)
59*49cdfc7eSAndroid Build Coastguard Worker {
60*49cdfc7eSAndroid Build Coastguard Worker int lc;
61*49cdfc7eSAndroid Build Coastguard Worker
62*49cdfc7eSAndroid Build Coastguard Worker tst_parse_opts(ac, av, NULL, NULL);
63*49cdfc7eSAndroid Build Coastguard Worker
64*49cdfc7eSAndroid Build Coastguard Worker setup();
65*49cdfc7eSAndroid Build Coastguard Worker
66*49cdfc7eSAndroid Build Coastguard Worker for (lc = 0; TEST_LOOPING(lc); lc++) {
67*49cdfc7eSAndroid Build Coastguard Worker tst_count = 0;
68*49cdfc7eSAndroid Build Coastguard Worker
69*49cdfc7eSAndroid Build Coastguard Worker test1();
70*49cdfc7eSAndroid Build Coastguard Worker test2();
71*49cdfc7eSAndroid Build Coastguard Worker test3();
72*49cdfc7eSAndroid Build Coastguard Worker /* reset saved conditions */
73*49cdfc7eSAndroid Build Coastguard Worker if ((setrlimit(RLIMIT_NPROC, &save_rlim)) == -1) {
74*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(TBROK, cleanup, "setrlimit failed to reset "
75*49cdfc7eSAndroid Build Coastguard Worker "RLIMIT_NPROC, errno = %d", errno);
76*49cdfc7eSAndroid Build Coastguard Worker }
77*49cdfc7eSAndroid Build Coastguard Worker test4();
78*49cdfc7eSAndroid Build Coastguard Worker }
79*49cdfc7eSAndroid Build Coastguard Worker
80*49cdfc7eSAndroid Build Coastguard Worker cleanup();
81*49cdfc7eSAndroid Build Coastguard Worker tst_exit();
82*49cdfc7eSAndroid Build Coastguard Worker }
83*49cdfc7eSAndroid Build Coastguard Worker
84*49cdfc7eSAndroid Build Coastguard Worker /*
85*49cdfc7eSAndroid Build Coastguard Worker * test1 - Test for RLIMIT_NOFILE
86*49cdfc7eSAndroid Build Coastguard Worker */
test1(void)87*49cdfc7eSAndroid Build Coastguard Worker static void test1(void)
88*49cdfc7eSAndroid Build Coastguard Worker {
89*49cdfc7eSAndroid Build Coastguard Worker rlim.rlim_cur = 100;
90*49cdfc7eSAndroid Build Coastguard Worker rlim.rlim_max = 100;
91*49cdfc7eSAndroid Build Coastguard Worker
92*49cdfc7eSAndroid Build Coastguard Worker TEST(setrlimit(RLIMIT_NOFILE, &rlim));
93*49cdfc7eSAndroid Build Coastguard Worker
94*49cdfc7eSAndroid Build Coastguard Worker if (TEST_RETURN == -1) {
95*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TFAIL, "setrlimit failed to set "
96*49cdfc7eSAndroid Build Coastguard Worker "RLIMIT_NOFILE, errno = %d", errno);
97*49cdfc7eSAndroid Build Coastguard Worker return;
98*49cdfc7eSAndroid Build Coastguard Worker }
99*49cdfc7eSAndroid Build Coastguard Worker
100*49cdfc7eSAndroid Build Coastguard Worker nofiles = getdtablesize();
101*49cdfc7eSAndroid Build Coastguard Worker
102*49cdfc7eSAndroid Build Coastguard Worker if (nofiles != 100) {
103*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TFAIL, "setrlimit failed, expected "
104*49cdfc7eSAndroid Build Coastguard Worker "100, got %d", nofiles);
105*49cdfc7eSAndroid Build Coastguard Worker return;
106*49cdfc7eSAndroid Build Coastguard Worker }
107*49cdfc7eSAndroid Build Coastguard Worker
108*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TPASS, "RLIMIT_NOFILE functionality is correct");
109*49cdfc7eSAndroid Build Coastguard Worker }
110*49cdfc7eSAndroid Build Coastguard Worker
111*49cdfc7eSAndroid Build Coastguard Worker /*
112*49cdfc7eSAndroid Build Coastguard Worker * test2 - Test for RLIMIT_FSIZE
113*49cdfc7eSAndroid Build Coastguard Worker */
test2(void)114*49cdfc7eSAndroid Build Coastguard Worker static void test2(void)
115*49cdfc7eSAndroid Build Coastguard Worker {
116*49cdfc7eSAndroid Build Coastguard Worker /*
117*49cdfc7eSAndroid Build Coastguard Worker * Since we would be altering the filesize in the child,
118*49cdfc7eSAndroid Build Coastguard Worker * we need to "sync", ie. fflush the parent's write buffers
119*49cdfc7eSAndroid Build Coastguard Worker * here. This is because the child will inherit the parent's
120*49cdfc7eSAndroid Build Coastguard Worker * write buffer, and while exiting it would try to fflush it.
121*49cdfc7eSAndroid Build Coastguard Worker * Since its filesize is truncated to only 10 bytes, the
122*49cdfc7eSAndroid Build Coastguard Worker * fflush attempt would fail, and the child would exit with
123*49cdfc7eSAndroid Build Coastguard Worker * an wired value! So, it is essential to fflush the parent's
124*49cdfc7eSAndroid Build Coastguard Worker * write buffer HERE
125*49cdfc7eSAndroid Build Coastguard Worker */
126*49cdfc7eSAndroid Build Coastguard Worker int pipefd[2];
127*49cdfc7eSAndroid Build Coastguard Worker fflush(stdout);
128*49cdfc7eSAndroid Build Coastguard Worker SAFE_PIPE(NULL, pipefd);
129*49cdfc7eSAndroid Build Coastguard Worker
130*49cdfc7eSAndroid Build Coastguard Worker /*
131*49cdfc7eSAndroid Build Coastguard Worker * Spawn a child process, and reduce the filesize to
132*49cdfc7eSAndroid Build Coastguard Worker * 10 by calling setrlimit(). We can't do this in the
133*49cdfc7eSAndroid Build Coastguard Worker * parent, because the parent needs a bigger filesize as its
134*49cdfc7eSAndroid Build Coastguard Worker * output will be saved to the logfile (instead of stdout)
135*49cdfc7eSAndroid Build Coastguard Worker * when the testcase (parent) is run from the driver.
136*49cdfc7eSAndroid Build Coastguard Worker */
137*49cdfc7eSAndroid Build Coastguard Worker pid = tst_fork();
138*49cdfc7eSAndroid Build Coastguard Worker if (pid == -1)
139*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(TBROK, cleanup, "fork() failed");
140*49cdfc7eSAndroid Build Coastguard Worker
141*49cdfc7eSAndroid Build Coastguard Worker if (pid == 0) {
142*49cdfc7eSAndroid Build Coastguard Worker close(pipefd[0]); /* close unused read end */
143*49cdfc7eSAndroid Build Coastguard Worker rlim.rlim_cur = 10;
144*49cdfc7eSAndroid Build Coastguard Worker rlim.rlim_max = 10;
145*49cdfc7eSAndroid Build Coastguard Worker if ((setrlimit(RLIMIT_FSIZE, &rlim)) == -1)
146*49cdfc7eSAndroid Build Coastguard Worker exit(1);
147*49cdfc7eSAndroid Build Coastguard Worker
148*49cdfc7eSAndroid Build Coastguard Worker fd = creat(filename, 0644);
149*49cdfc7eSAndroid Build Coastguard Worker if (fd < 0)
150*49cdfc7eSAndroid Build Coastguard Worker exit(2);
151*49cdfc7eSAndroid Build Coastguard Worker
152*49cdfc7eSAndroid Build Coastguard Worker bytes = write(fd, buf, 26);
153*49cdfc7eSAndroid Build Coastguard Worker if (bytes != 10) {
154*49cdfc7eSAndroid Build Coastguard Worker if (write(pipefd[1], &bytes, sizeof(bytes)) < (long)sizeof(bytes)) {
155*49cdfc7eSAndroid Build Coastguard Worker perror("child: write to pipe failed");
156*49cdfc7eSAndroid Build Coastguard Worker }
157*49cdfc7eSAndroid Build Coastguard Worker close(pipefd[1]); /* EOF */
158*49cdfc7eSAndroid Build Coastguard Worker exit(3);
159*49cdfc7eSAndroid Build Coastguard Worker }
160*49cdfc7eSAndroid Build Coastguard Worker exit(0); /* success */
161*49cdfc7eSAndroid Build Coastguard Worker }
162*49cdfc7eSAndroid Build Coastguard Worker
163*49cdfc7eSAndroid Build Coastguard Worker /* parent */
164*49cdfc7eSAndroid Build Coastguard Worker SAFE_WAITPID(cleanup, pid, &status, 0);
165*49cdfc7eSAndroid Build Coastguard Worker
166*49cdfc7eSAndroid Build Coastguard Worker switch (WEXITSTATUS(status)) {
167*49cdfc7eSAndroid Build Coastguard Worker case 0:
168*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TPASS, "RLIMIT_FSIZE test PASSED");
169*49cdfc7eSAndroid Build Coastguard Worker break;
170*49cdfc7eSAndroid Build Coastguard Worker case 1:
171*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TFAIL, "setrlimit failed to set "
172*49cdfc7eSAndroid Build Coastguard Worker "RLIMIT_FSIZE, errno = %d", errno);
173*49cdfc7eSAndroid Build Coastguard Worker break;
174*49cdfc7eSAndroid Build Coastguard Worker case 2:
175*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TFAIL, "creating testfile failed");
176*49cdfc7eSAndroid Build Coastguard Worker break;
177*49cdfc7eSAndroid Build Coastguard Worker case 3:
178*49cdfc7eSAndroid Build Coastguard Worker close(pipefd[1]); /* close unused write end */
179*49cdfc7eSAndroid Build Coastguard Worker if (read(pipefd[0], &bytes, sizeof(bytes)) < (long)sizeof(bytes))
180*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TFAIL, "parent: reading pipe failed");
181*49cdfc7eSAndroid Build Coastguard Worker
182*49cdfc7eSAndroid Build Coastguard Worker close(pipefd[0]);
183*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TFAIL, "setrlimit failed, expected "
184*49cdfc7eSAndroid Build Coastguard Worker "10 got %d", bytes);
185*49cdfc7eSAndroid Build Coastguard Worker break;
186*49cdfc7eSAndroid Build Coastguard Worker default:
187*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TFAIL, "child returned bad exit status");
188*49cdfc7eSAndroid Build Coastguard Worker }
189*49cdfc7eSAndroid Build Coastguard Worker }
190*49cdfc7eSAndroid Build Coastguard Worker
191*49cdfc7eSAndroid Build Coastguard Worker /*
192*49cdfc7eSAndroid Build Coastguard Worker * test3 - Test for RLIMIT_NPROC
193*49cdfc7eSAndroid Build Coastguard Worker */
test3(void)194*49cdfc7eSAndroid Build Coastguard Worker static void test3(void)
195*49cdfc7eSAndroid Build Coastguard Worker {
196*49cdfc7eSAndroid Build Coastguard Worker SAFE_GETRLIMIT(cleanup, RLIMIT_NPROC, &save_rlim);
197*49cdfc7eSAndroid Build Coastguard Worker
198*49cdfc7eSAndroid Build Coastguard Worker rlim.rlim_cur = 10;
199*49cdfc7eSAndroid Build Coastguard Worker rlim.rlim_max = 10;
200*49cdfc7eSAndroid Build Coastguard Worker
201*49cdfc7eSAndroid Build Coastguard Worker TEST(setrlimit(RLIMIT_NPROC, &rlim));
202*49cdfc7eSAndroid Build Coastguard Worker
203*49cdfc7eSAndroid Build Coastguard Worker if (TEST_RETURN == -1) {
204*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TFAIL, "setrlimit failed to set "
205*49cdfc7eSAndroid Build Coastguard Worker "RLIMIT_NPROC, errno = %d", errno);
206*49cdfc7eSAndroid Build Coastguard Worker return;
207*49cdfc7eSAndroid Build Coastguard Worker }
208*49cdfc7eSAndroid Build Coastguard Worker
209*49cdfc7eSAndroid Build Coastguard Worker if ((getrlimit(RLIMIT_NPROC, &rlim1)) == -1) {
210*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(TBROK, cleanup, "getrlimit failed to get "
211*49cdfc7eSAndroid Build Coastguard Worker "values for RLIMIT_NPROC, errno = %d", errno);
212*49cdfc7eSAndroid Build Coastguard Worker }
213*49cdfc7eSAndroid Build Coastguard Worker
214*49cdfc7eSAndroid Build Coastguard Worker if ((rlim1.rlim_cur != 10) && (rlim1.rlim_max != 10)) {
215*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TFAIL, "setrlimit did not set the proc "
216*49cdfc7eSAndroid Build Coastguard Worker "limit correctly");
217*49cdfc7eSAndroid Build Coastguard Worker return;
218*49cdfc7eSAndroid Build Coastguard Worker }
219*49cdfc7eSAndroid Build Coastguard Worker
220*49cdfc7eSAndroid Build Coastguard Worker for (i = 0; i < 20; i++) {
221*49cdfc7eSAndroid Build Coastguard Worker pid = tst_fork();
222*49cdfc7eSAndroid Build Coastguard Worker if (pid == -1) {
223*49cdfc7eSAndroid Build Coastguard Worker if (errno != EAGAIN) {
224*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TWARN, "Expected EAGAIN got %d",
225*49cdfc7eSAndroid Build Coastguard Worker errno);
226*49cdfc7eSAndroid Build Coastguard Worker }
227*49cdfc7eSAndroid Build Coastguard Worker } else if (pid == 0) {
228*49cdfc7eSAndroid Build Coastguard Worker exit(0);
229*49cdfc7eSAndroid Build Coastguard Worker }
230*49cdfc7eSAndroid Build Coastguard Worker }
231*49cdfc7eSAndroid Build Coastguard Worker waitpid(pid, &status, 0);
232*49cdfc7eSAndroid Build Coastguard Worker if (WEXITSTATUS(status) != 0)
233*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TFAIL, "RLIMIT_NPROC functionality is not correct");
234*49cdfc7eSAndroid Build Coastguard Worker else
235*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TPASS, "RLIMIT_NPROC functionality is correct");
236*49cdfc7eSAndroid Build Coastguard Worker }
237*49cdfc7eSAndroid Build Coastguard Worker
238*49cdfc7eSAndroid Build Coastguard Worker /*
239*49cdfc7eSAndroid Build Coastguard Worker * test4() - Test for RLIMIT_CORE by forking a child and
240*49cdfc7eSAndroid Build Coastguard Worker * having it cause a segfault
241*49cdfc7eSAndroid Build Coastguard Worker */
test4(void)242*49cdfc7eSAndroid Build Coastguard Worker static void test4(void)
243*49cdfc7eSAndroid Build Coastguard Worker {
244*49cdfc7eSAndroid Build Coastguard Worker rlim.rlim_cur = 10;
245*49cdfc7eSAndroid Build Coastguard Worker rlim.rlim_max = 10;
246*49cdfc7eSAndroid Build Coastguard Worker
247*49cdfc7eSAndroid Build Coastguard Worker TEST(setrlimit(RLIMIT_CORE, &rlim));
248*49cdfc7eSAndroid Build Coastguard Worker
249*49cdfc7eSAndroid Build Coastguard Worker if (TEST_RETURN == -1) {
250*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TFAIL | TTERRNO, "setrlimit failed to set RLIMIT_CORE");
251*49cdfc7eSAndroid Build Coastguard Worker return;
252*49cdfc7eSAndroid Build Coastguard Worker }
253*49cdfc7eSAndroid Build Coastguard Worker
254*49cdfc7eSAndroid Build Coastguard Worker pid = tst_fork();
255*49cdfc7eSAndroid Build Coastguard Worker if (pid == -1)
256*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(TBROK, cleanup, "fork() failed");
257*49cdfc7eSAndroid Build Coastguard Worker
258*49cdfc7eSAndroid Build Coastguard Worker if (pid == 0) { /* child */
259*49cdfc7eSAndroid Build Coastguard Worker char *testbuf = NULL;
260*49cdfc7eSAndroid Build Coastguard Worker strcpy(testbuf, "abcd");
261*49cdfc7eSAndroid Build Coastguard Worker exit(0);
262*49cdfc7eSAndroid Build Coastguard Worker }
263*49cdfc7eSAndroid Build Coastguard Worker wait(&status);
264*49cdfc7eSAndroid Build Coastguard Worker
265*49cdfc7eSAndroid Build Coastguard Worker if (access("core", F_OK) == 0) {
266*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TFAIL, "core dump dumped unexpectedly");
267*49cdfc7eSAndroid Build Coastguard Worker return;
268*49cdfc7eSAndroid Build Coastguard Worker } else if (errno != ENOENT) {
269*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TFAIL | TERRNO, "access failed unexpectedly");
270*49cdfc7eSAndroid Build Coastguard Worker return;
271*49cdfc7eSAndroid Build Coastguard Worker }
272*49cdfc7eSAndroid Build Coastguard Worker
273*49cdfc7eSAndroid Build Coastguard Worker tst_resm(TPASS, "RLIMIT_CORE functionality is correct");
274*49cdfc7eSAndroid Build Coastguard Worker }
275*49cdfc7eSAndroid Build Coastguard Worker
276*49cdfc7eSAndroid Build Coastguard Worker /*
277*49cdfc7eSAndroid Build Coastguard Worker * sighandler() - catch sigsegv when generated by child in test #4
278*49cdfc7eSAndroid Build Coastguard Worker */
sighandler(int sig)279*49cdfc7eSAndroid Build Coastguard Worker static void sighandler(int sig)
280*49cdfc7eSAndroid Build Coastguard Worker {
281*49cdfc7eSAndroid Build Coastguard Worker if (sig != SIGSEGV && sig != SIGXFSZ && sig != SIGTERM)
282*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(TBROK, NULL, "caught unexpected signal: %d", sig);
283*49cdfc7eSAndroid Build Coastguard Worker
284*49cdfc7eSAndroid Build Coastguard Worker _exit(0);
285*49cdfc7eSAndroid Build Coastguard Worker }
286*49cdfc7eSAndroid Build Coastguard Worker
setup(void)287*49cdfc7eSAndroid Build Coastguard Worker static void setup(void)
288*49cdfc7eSAndroid Build Coastguard Worker {
289*49cdfc7eSAndroid Build Coastguard Worker tst_require_root();
290*49cdfc7eSAndroid Build Coastguard Worker
291*49cdfc7eSAndroid Build Coastguard Worker umask(0);
292*49cdfc7eSAndroid Build Coastguard Worker
293*49cdfc7eSAndroid Build Coastguard Worker tst_sig(FORK, sighandler, cleanup);
294*49cdfc7eSAndroid Build Coastguard Worker
295*49cdfc7eSAndroid Build Coastguard Worker TEST_PAUSE;
296*49cdfc7eSAndroid Build Coastguard Worker
297*49cdfc7eSAndroid Build Coastguard Worker tst_tmpdir();
298*49cdfc7eSAndroid Build Coastguard Worker
299*49cdfc7eSAndroid Build Coastguard Worker sprintf(filename, "setrlimit1.%d", getpid());
300*49cdfc7eSAndroid Build Coastguard Worker }
301*49cdfc7eSAndroid Build Coastguard Worker
cleanup(void)302*49cdfc7eSAndroid Build Coastguard Worker static void cleanup(void)
303*49cdfc7eSAndroid Build Coastguard Worker {
304*49cdfc7eSAndroid Build Coastguard Worker unlink(filename);
305*49cdfc7eSAndroid Build Coastguard Worker tst_rmdir();
306*49cdfc7eSAndroid Build Coastguard Worker }
307