This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Shared Memory Access Problem
- From: Bob Furber <burnsmicro at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 07 Sep 2012 16:03:32 -0700
- Subject: Shared Memory Access Problem
- Reply-to: burnsmicro at gmail dot com
I have 2 programs that communicate through shared memory that work fine
when I have root privileges, but fail when I sign on as a user. The
server program that creates the shared memory set read an write
permissions to allow everyone to access this memory (rw-rw-rw-).
ShmID = shmget(ShmKEY, sizeof(struct Memory), IPC_CREAT | 0666);
Likewise, the client program, which is started after the server, creates
the shared memory with rw-rw-rw- permissions.
ShmID = shmget(ShmKEY, sizeof(struct Memory), 0666);
But, when I run the client program without root privileges,shmget()
returns -1 and errno = 2 which supposedly means "File/Directory not found".
Why is the client capable of accessing shared memory when executed by
root and not able to, when executed by a user?
I should mention that both the server and client executables have been
chmoded to 777.