1#define _GNU_SOURCE 2#include <stdio.h> 3#include <stdlib.h> 4#include <assert.h> 5#include <sys/ipc.h> 6#include <sys/shm.h> 7#include <sys/stat.h> 8#include <sys/mman.h> 9 10int main() 11{ 12 int shmid = shmget(IPC_PRIVATE, 100 * 4096, 13 IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR); 14 assert(shmid != -1); 15 16 void *addr = shmat(shmid, NULL, 0); 17 assert(addr != (void *)-1); 18 19 addr = mremap(addr, 100 * 4096, 40 * 4096, 0); 20 assert(addr != (void *)-1); 21 22 return 0; 23} 24