changing mmap() permissions

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Kevin Buettner
Date:  
Subject: changing mmap() permissions
On Aug 20, 11:44am, Randy Kaelber wrote:

> I'm trying to implement a distributed shared memory system using network
> sockets and mmap(). A problem I have run into is that I want to protect
> segments of memory from being written to by a process. While it's easy
> enough to mmap() a region read only, What I want to do is receive a
> chunk of data from a remote process, mmap() it to a specific address,
> and then make that block read-only, such that if a process tries to
> write it after I've copied it in, it will get a seg fault. If I start
> read only, I cannot copy data to the region at all.


Take a look at mprotect().

Kevin