Subject: Re: [boost] Need help >> Boost's managed_shared_memory usage in between two processes (C and C++)
From: Ion GaztaÃ±aga (igaztanaga_at_[hidden])
Date: 2017-10-08 09:15:16
On 08/10/2017 10:18, vijay sharma via Boost wrote:
> Once I have addr pointer, I am using memcpy to write in SHM.
You shouldn't pass raw pointers to another application, usually pointers
are only valid inside a process and invalid outside it. Only the
distance between the start of the shared memory and an address inside
that shared memory is common for both processes.
Boost.Interprocess is not prepared to be used from a C application.
Maybe you can try the following:
Take an address of an position in shared memory in application 1 and
call get_handle_from_address. Then pass the handle (usually of type
size_t, an unsigned integer) using something like pipes or message
queues, or a well-known shared memory address so that process 2 can
access to it. Then the C application can map the shared memory, and add
the base address of that shared memory, add the given handle/offset, and
obtain the address of the wanted position in the shared memory for the
In any case the code you've posted is invalid.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk