Remove building with NOCRYPTO option
[minix.git] / minix / tests / test4.c
blobe7156bf4ba2dd9ddb2d2672fa6847acfa18d0990
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 int max_error = 2;
19 #include "common.h"
23 int main(void);
24 void subr(void);
25 void nofork(void);
26 void quit(void);
28 int main()
30 int k;
32 start(4);
34 creat(tempfile, 0777);
35 for (k = 0; k < 20; k++) {
36 subr();
38 unlink(tempfile);
39 quit();
40 return(-1); /* impossible */
43 void subr()
45 if ( (pid0 = fork()) != 0) {
46 /* Parent 0 */
47 if (pid0 < 0) nofork();
48 if ( (pid1 = fork()) != 0) {
49 /* Parent 1 */
50 if (pid1 < 0) nofork();
51 if ( (pid2 = fork()) != 0) {
52 /* Parent 2 */
53 if (pid2 < 0) nofork();
54 if ( (pid3 = fork()) != 0) {
55 /* Parent 3 */
56 if (pid3 < 0) nofork();
57 for (i = 0; i < 10000; i++);
58 kill(pid2, SIGKILL);
59 kill(pid1, SIGKILL);
60 kill(pid0, SIGKILL);
61 wait(&s);
62 wait(&s);
63 wait(&s);
64 wait(&s);
65 } else {
66 fd = open(tempfile, O_RDONLY);
67 lseek(fd, 20480L * nextb, 0);
68 for (i = 0; i < 10; i++) read(fd, buf, 1024);
69 nextb++;
70 close(fd);
71 exit(0);
73 } else {
74 while (1) getpid();
76 } else {
77 while (1) getpid();
79 } else {
80 while (1) getpid();
84 void nofork()
86 int e = errno;
87 printf("Fork failed: %s (%d)\n",strerror(e),e);
88 exit(1);