mkfs: symlink support
[minix.git] / test / test4.c
blob877ac4948eab89938092c117424267e2f6d79c01
1 /* test 4 */
3 #include <sys/types.h>
4 #include <sys/wait.h>
5 #include <fcntl.h>
6 #include <signal.h>
7 #include <stdlib.h>
8 #include <unistd.h>
9 #include <stdio.h>
10 #include <string.h>
11 #include <errno.h>
13 pid_t pid0, pid1, pid2, pid3;
14 int s, i, fd, nextb;
15 char *tempfile = "test4.temp";
16 char buf[1024];
18 #define MAX_ERROR 2
20 #include "common.c"
22 int main(void);
23 void subr(void);
24 void nofork(void);
25 void quit(void);
27 int main()
29 int k;
31 start(4);
33 creat(tempfile, 0777);
34 for (k = 0; k < 20; k++) {
35 subr();
37 unlink(tempfile);
38 quit();
39 return(-1); /* impossible */
42 void subr()
44 if ( (pid0 = fork()) != 0) {
45 /* Parent 0 */
46 if (pid0 < 0) nofork();
47 if ( (pid1 = fork()) != 0) {
48 /* Parent 1 */
49 if (pid1 < 0) nofork();
50 if ( (pid2 = fork()) != 0) {
51 /* Parent 2 */
52 if (pid2 < 0) nofork();
53 if ( (pid3 = fork()) != 0) {
54 /* Parent 3 */
55 if (pid3 < 0) nofork();
56 for (i = 0; i < 10000; i++);
57 kill(pid2, 9);
58 kill(pid1, 9);
59 kill(pid0, 9);
60 wait(&s);
61 wait(&s);
62 wait(&s);
63 wait(&s);
64 } else {
65 fd = open(tempfile, O_RDONLY);
66 lseek(fd, 20480L * nextb, 0);
67 for (i = 0; i < 10; i++) read(fd, buf, 1024);
68 nextb++;
69 close(fd);
70 exit(0);
72 } else {
73 while (1) getpid();
75 } else {
76 while (1) getpid();
78 } else {
79 while (1) getpid();
83 void nofork()
85 int e = errno;
86 printf("Fork failed: %s (%d)\n",strerror(e),e);
87 exit(1);