forked from Stichting-MINIX-Research-Foundation/minix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest12.c
More file actions
55 lines (42 loc) · 880 Bytes
/
Copy pathtest12.c
File metadata and controls
55 lines (42 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* test 12 */
/* Copyright (C) 1987 by Martin Leisner. All rights reserved. */
/* Used by permission. */
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#define NUM_TIMES 1000
int errct = 0;
_PROTOTYPE(int main, (void));
_PROTOTYPE(void quit, (void));
int main()
{
register int i;
int k;
printf("Test 12 ");
fflush(stdout); /* have to flush for child's benefit */
system("rm -rf DIR_12; mkdir DIR_12");
chdir("DIR_12");
for (i = 0; i < NUM_TIMES; i++) switch (fork()) {
case 0: exit(1); break;
case -1:
printf("fork broke\n");
exit(1);
default: wait(&k); break;
}
quit();
return(-1); /* impossible */
}
void quit()
{
chdir("..");
system("rm -rf DIR*");
if (errct == 0) {
printf("ok\n");
exit(0);
} else {
printf("%d errors\n", errct);
exit(1);
}
}