blob: e42e38f93af39f7b25439a70d94da0efffeebf70 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# Inter Process Communication
March 14, 2018
We can attach nicely to same memory segment from 2 different processes:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.c .numberLines}
// ipc via shared mem
// attach to shared memory;
key_t my_ftok = ftok("~/surf-webext-dom-shared-mem",'a');
int mem_seg=shmget(my_ftok,1024*1024,IPC_CREAT|0660);
if(mem_seg==-1)
{
g_print("shmget failed: %s\n",strerror(errno));
}
shared_buf=shmat(mem_seg,NULL,0);
if(shared_buf==(void*)-1)
{
g_print("shmat failed: %s\n",strerror(errno));
}
g_print("attached to shared memory.\n");
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|