If a client wants to use a shared memory created with IPC_PRIVATE, it must be a child process of the server, created after the parent has obtained the shared memory, so that the child can attach the memory after it has been created.
Server and clients can have a parent/client relationship or run as separate and unrelated processes. In the former case, if a shared memory is requested and attached prior to forking the child client process, then the server may want to use IPC_PRIVATE since the child receives an identical copy of the server’s address space which includes the attached shared memory. However, if the server and clients are separate processes, using IPC_PRIVATE is unwise since the clients will not be able to request the same shared memory segment with a unique and unknown key. In this case, you need to utilize ftok to generate key. With the same path as parameter, ftok will generate the same key.
reference:
KING FAHD UNIVERSITY OF PETROLEUM AND MINERALS
ICS 431 Operating Systems Lab # 14
ya its good…
Thank you.