How it works...
We will invoke the ftok function to generate an IPC key. The filename and ID that are supplied for generating the key are sharedmem (any name) and a, respectively. The generated key is assigned to the key variable. Thereafter, we will invoke the shmget function to allocate a shared memory segment. The size that's specified for the allocated memory segment is 1024 and is associated with the IPC key that was generated earlier.
We will create the new memory segment with read and write permissions and assign the fetched shared memory identifier to the shmid variable. The shared memory segment is then attached to the first available address in the system. This is done so that we can access the text that was written in the shared ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access