The memory can be shared between processes through a series of functions such as shmget/shmat.
With reference to these blogs, we can achieve:
Http://nnssll.blog.51cto.com/902724/199808 (the original is wrong, pay attention to view the comment)
Http://wellwy.blog.51cto.com/1609602/492083
However, some difficulties were encountered during the attempt:
Shm_addr = (char *) shmat (shm_id, null, 0 );-1 is returned.
Perror:Permission denied
I checked some information on the Internet, saying that I had to add 0666 permissions to shmget, for example:
Shm_id = shmget (Key, 4096, ipc_creat |0666);
But it still does not work.
When I thought about ftok, I used a filepath.
Key = ftok (filepath, 0 );
This ftok must already have a real file. Is it a File Permission problem?
After chmod 777 filepath is used, it is enough...
If not, you can run sudo.ProgramTry it.