1*49cdfc7eSAndroid Build Coastguard Worker /*
2*49cdfc7eSAndroid Build Coastguard Worker * Copyright (C) 2012-2015 Cyril Hrubis <[email protected]>
3*49cdfc7eSAndroid Build Coastguard Worker *
4*49cdfc7eSAndroid Build Coastguard Worker * This program is free software; you can redistribute it and/or modify it
5*49cdfc7eSAndroid Build Coastguard Worker * under the terms of version 2 of the GNU General Public License as
6*49cdfc7eSAndroid Build Coastguard Worker * published by the Free Software Foundation.
7*49cdfc7eSAndroid Build Coastguard Worker *
8*49cdfc7eSAndroid Build Coastguard Worker * This program is distributed in the hope that it would be useful, but
9*49cdfc7eSAndroid Build Coastguard Worker * WITHOUT ANY WARRANTY; without even the implied warranty of
10*49cdfc7eSAndroid Build Coastguard Worker * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11*49cdfc7eSAndroid Build Coastguard Worker *
12*49cdfc7eSAndroid Build Coastguard Worker * Further, this software is distributed without any warranty that it is
13*49cdfc7eSAndroid Build Coastguard Worker * free of the rightful claim of any third person regarding infringement
14*49cdfc7eSAndroid Build Coastguard Worker * or the like. Any license provided herein, whether implied or
15*49cdfc7eSAndroid Build Coastguard Worker * otherwise, applies only to this software file. Patent licenses, if
16*49cdfc7eSAndroid Build Coastguard Worker * any, provided herein do not apply to combinations of this program with
17*49cdfc7eSAndroid Build Coastguard Worker * other software, or any other product whatsoever.
18*49cdfc7eSAndroid Build Coastguard Worker *
19*49cdfc7eSAndroid Build Coastguard Worker * You should have received a copy of the GNU General Public License along
20*49cdfc7eSAndroid Build Coastguard Worker * with this program; if not, write the Free Software Foundation, Inc.,
21*49cdfc7eSAndroid Build Coastguard Worker * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22*49cdfc7eSAndroid Build Coastguard Worker */
23*49cdfc7eSAndroid Build Coastguard Worker
24*49cdfc7eSAndroid Build Coastguard Worker #include <sys/wait.h>
25*49cdfc7eSAndroid Build Coastguard Worker
26*49cdfc7eSAndroid Build Coastguard Worker #include "test.h"
27*49cdfc7eSAndroid Build Coastguard Worker
28*49cdfc7eSAndroid Build Coastguard Worker char *TCID = "tst_checkpoint";
29*49cdfc7eSAndroid Build Coastguard Worker int TST_TOTAL = 1;
30*49cdfc7eSAndroid Build Coastguard Worker
main(void)31*49cdfc7eSAndroid Build Coastguard Worker int main(void)
32*49cdfc7eSAndroid Build Coastguard Worker {
33*49cdfc7eSAndroid Build Coastguard Worker int pid;
34*49cdfc7eSAndroid Build Coastguard Worker
35*49cdfc7eSAndroid Build Coastguard Worker tst_tmpdir();
36*49cdfc7eSAndroid Build Coastguard Worker
37*49cdfc7eSAndroid Build Coastguard Worker TST_CHECKPOINT_INIT(tst_rmdir);
38*49cdfc7eSAndroid Build Coastguard Worker
39*49cdfc7eSAndroid Build Coastguard Worker pid = fork();
40*49cdfc7eSAndroid Build Coastguard Worker
41*49cdfc7eSAndroid Build Coastguard Worker switch (pid) {
42*49cdfc7eSAndroid Build Coastguard Worker case -1:
43*49cdfc7eSAndroid Build Coastguard Worker tst_brkm(TBROK | TERRNO, NULL, "Fork failed");
44*49cdfc7eSAndroid Build Coastguard Worker break;
45*49cdfc7eSAndroid Build Coastguard Worker case 0:
46*49cdfc7eSAndroid Build Coastguard Worker fprintf(stderr, "Child: checkpoint signaling\n");
47*49cdfc7eSAndroid Build Coastguard Worker TST_SAFE_CHECKPOINT_WAKE(NULL, 0);
48*49cdfc7eSAndroid Build Coastguard Worker exit(0);
49*49cdfc7eSAndroid Build Coastguard Worker break;
50*49cdfc7eSAndroid Build Coastguard Worker default:
51*49cdfc7eSAndroid Build Coastguard Worker TST_SAFE_CHECKPOINT_WAIT(tst_rmdir, 0);
52*49cdfc7eSAndroid Build Coastguard Worker fprintf(stderr, "Parent: checkpoint reached\n");
53*49cdfc7eSAndroid Build Coastguard Worker break;
54*49cdfc7eSAndroid Build Coastguard Worker }
55*49cdfc7eSAndroid Build Coastguard Worker
56*49cdfc7eSAndroid Build Coastguard Worker wait(NULL);
57*49cdfc7eSAndroid Build Coastguard Worker tst_rmdir();
58*49cdfc7eSAndroid Build Coastguard Worker return 0;
59*49cdfc7eSAndroid Build Coastguard Worker }
60