shm_open() allows multiple un-related processes to access the same shared memory - since it can be accessed by a well know name.
shmget() requires some way for the creating process to give the 'key' used to create the memory to other processes so they can access it. sometimes the creating process writes the 'key' to a well known file name so that other un-related processes can read the key.
if the creating process only needs to share the memory with child processes created via fork(), then shmget() is ok; otherwise, shm_open() is often used.
在跨用戶訪問共享內存時,shm_open會好一些,因為它的文件是放在/dev/shm的這么一個公共目錄。 shmget還要特意找一個區域讓多用戶共享,然后再生成個不會被刪除的文件來生成共享key,這樣不如shm_open來的直接和明確。