#include #include #include #include #include #include int main() { const char msg[] = "hello world"; size_t msglen = strlen(msg) + 1; int shmd = shm_open("/shm", O_RDONLY, 0755); ftruncate(shmd, msglen); char* memory = mmap(NULL, msglen, PROT_READ, MAP_SHARED, shmd, 0); char buf[1024]; strncpy(buf, memory, msglen); write(1, buf, msglen); munmap(memory, msglen); close(shmd); shm_unlink("/shm"); return 0; }