12 pid_t pid0
, pid1
, pid2
, pid3
;
13 int s
, i
, fd
, nextb
, errct
= 0;
14 char *tempfile
= "test4.temp";
18 _PROTOTYPE(int main
, (void));
19 _PROTOTYPE(void subr
, (void));
20 _PROTOTYPE(void nofork
, (void));
21 _PROTOTYPE(void quit
, (void));
28 fflush(stdout
); /* have to flush for child's benefit */
30 system("rm -rf DIR_04; mkdir DIR_04");
33 creat(tempfile
, 0777);
34 for (k
= 0; k
< 20; k
++) {
39 return(-1); /* impossible */
44 if ( (pid0
= fork()) != 0) {
46 if (pid0
< 0) nofork();
47 if ( (pid1
= fork()) != 0) {
49 if (pid1
< 0) nofork();
50 if ( (pid2
= fork()) != 0) {
52 if (pid2
< 0) nofork();
53 if ( (pid3
= fork()) != 0) {
55 if (pid3
< 0) nofork();
56 for (i
= 0; i
< 10000; i
++);
65 fd
= open(tempfile
, O_RDONLY
);
66 lseek(fd
, 20480L * nextb
, 0);
67 for (i
= 0; i
< 10; i
++) read(fd
, buf
, 1024);
86 printf("Fork failed: %s (%d)\n",strerror(e
),e
);
94 system("rm -rf DIR*");
100 printf("%d errors\n", errct
);