/* * Exemplo de arquivo mapeado em memória */ #include #include #include #include #include #include #include int main() { int fd; char* map; fd = open ("teste.txt", O_RDWR); map = mmap (NULL, 100, PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0); if (fork()) { char *str = "Eu sou o pai "; printf("%s", map); strcpy(map, str); } else { char *str = "Eu sou o filho"; strcpy(map, str); } munmap(map, 100); close(fd); return 0; }