/* hold.c - malloc and touch 1 MB, attach 1 MB shm, then wait, so svmon can look. */ #include #include #include #include #include int main(void){ char *p = malloc(1<<20); long i; int id; void *s; for (i = 0; i < (1<<20); i += 4096) p[i] = 1; id = shmget(IPC_PRIVATE, 1<<20, IPC_CREAT|0600); s = shmat(id, 0, 0); shmctl(id, IPC_RMID, 0); ((char*)s)[0] = 1; printf("pid %d heap %p shm %p\n", (int)getpid(), (void*)p, s); fflush(stdout); sleep(240); return 0; }