shared memory after exec()
问题 How can I share memory between the parent and the child if the child has run exec() to load another program? Is it possible using mmap ? By now parent and child share memory properly using mmap, but not after exec is done 回答1: You can use shm_open to open a "named" shared memory block which is identified by a file on the filesystem. Example: In the parent: int memFd = shm_open("example_memory", O_CREAT | O_RDWR, S_IRWXU); if (memFd == -1) { perror("Can't open file"); return 1; } int res =