I have a structure that looks like this:
typedef struct shared_data_t { char *key; char *message; }shared_data;
I need to share this structure with another unrelated process. To achieve this, I use POSIX shared memory with shm_open () / mmap (). However, my target process does not receive general data and its skill with SIGSEGV, which is obvious. It will be great if someone helps me with this, especially what happens when pointers are shared between two shared memory processes (using shm_open and mmap).
For a structure like
typedef struct shared_data_t { char key[8]; char message[32]; }shared_data;
it works great!
Linux : shmat:
shmat
Using shmat() with shmaddr equal to NULL is the preferred, portable way of attaching a shared memory segment. Be aware that the shared memory segment attached in this way may be attached at different addresses in different processes. Therefore, any pointers maintained within the shared memory must be made relative (typically to the starting address of the segment), rather than absolute.
key message. , 0x1000 0x1040. , , 0x7000. . , , 0x9000. . , key message 0x1000 0x1040. . , .
key
message
, key message , ( mmap , , ), , key message. . char (, ptrdiff_t), . .
mmap
char
ptrdiff_t
, - , shared_data: , , . , , .
shared_data
Source: https://habr.com/ru/post/1527316/More articles:Dart, reflection and source maps? - dartref keyword when passing an uninitialized parameter to a method - c #Client cannot connect to RabbitMQ server on localhost - phpObjective-C: access to instance variables declared as @private - classHow to create unique random numbers in matlab? - matlabThe static member function is not accepted as a constexpr parameter - c ++https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1527318/python-markdown-add-class-to-table&usg=ALkJrhh97oJ_dZjvn3l1YAiBtvNXdKT47gLimit spaces PyCharm - intellij-ideaMVC ListBox mutiple selects only one value in the controller per post - c #Permanent automatic reconnection of EventSource - javascriptAll Articles