Re: Posix shared memory - permission problems?
Re: Posix shared memory - permission problems?
- Subject: Re: Posix shared memory - permission problems?
- From: Terry Lambert <email@hidden>
- Date: Wed, 19 Sep 2007 15:46:44 -0700
On Sep 19, 2007, at 8:32 AM, Tom O'Grady wrote:
[creating read only shared memory using same name]:
CLockMutex mutexSection(mutex); // mutex created using posix
semaphore.
SharedMemID = shm_open(memname, O_RDONLY, 0x777); // Create shared
memory with read access.
struct stat fstats;
fstat(SharedMemID, &fstats); // check to see if the memory has been
allocated and initialised
// In this case, the size is already set and the permissions are set
to 0x777. Therefore no truncation is required - I just map the memory:
smptr = mmap( 0, size, PROT_READ, MAP_SHARED, SharedMemID, 0 );
I suspect that in your real code you are specifying O_CREAT in the
O_RDNOLY case, and that is causing the mode to get rest on the shared
memory object. If you're not sure if the shared memory exists, you
should specify O_EXCL on the create, which will prevent it from being
created if it already exists.
-- Terry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden