/* shmonly.c - shmat with nothing else attached. */ #include #include #include #include #include int main(void) { int i, id; void *p; for (i = 0; i < 16; i++) { id = shmget(IPC_PRIVATE, 1<<20, IPC_CREAT|0600); p = shmat(id, 0, 0); shmctl(id, IPC_RMID, 0); if (p == (void*)-1) { printf("shmat %2d failed: errno %d %s\n", i+1, errno, strerror(errno)); break; } printf("shmat %2d %p\n", i+1, p); } return 0; }