t40c term[] count fix
[minix.git] / test / test64.c
blob52f741c1d466b700d8d731eac7e1aaa2f10af041
2 /* Code to test reasonable response to out-of-memory condition
3 * of regular processes.
4 */
6 #include <stdlib.h>
7 #include <stdio.h>
8 #include <dlfcn.h>
10 #include <sys/mman.h>
11 #include <sys/wait.h>
13 #define MAX_ERROR 2
15 #include "magic.h"
16 #include "common.c"
18 int main (int argc, char *argv[])
20 pid_t f;
21 start(64);
22 #define NADDRS 500
23 #define LEN 4096
24 static void *addrs[NADDRS];
25 int i = 0;
26 int st;
28 if((f=fork()) == -1) {
29 e(1);
30 exit(1);
33 if(f == 0) {
34 /* child: use up as much memory as we can */
35 while((addrs[i++ % NADDRS] = minix_mmap(0, LEN, PROT_READ|PROT_WRITE,
36 MAP_PREALLOC|MAP_CONTIG|MAP_ANON, -1, 0)) != MAP_FAILED)
38 exit(0);
41 /* parent: wait for child */
42 if(waitpid(f, &st, 0) < 0)
43 perror("waitpid");
45 quit();
47 return(0);