Posix shared memory problem

Jilles Tjoelker jilles at stack.nl
Sat May 9 20:07:27 UTC 2009


On Sat, May 09, 2009 at 08:31:15PM +0200, Lothar Scholz wrote:
> Thanks for solving the posix semaphore problem. But with shared memory
> there comes the next issue:

> int main() {
>   int m;
>   shm_unlink("/barfoo");
>   m = shm_open("/barfoo", O_RDWR|O_CREAT|O_EXCL, S_IRWXU);
>   if (m == 1) perror("shm_open error");
> }

> i always get permission denied error, and i tried many values
> for flags and mode? I can only get this working as root but not
> as a normal user.

shm_open/shm_unlink refer to the filesystem; they are fairly direct
wrappers around open and unlink.

POSIX suggests making the pathname a configuration option;
alternatively, using a directory for temporary files such as /tmp could
work.

-- 
Jilles Tjoelker


More information about the freebsd-arch mailing list