Find the answer to your Linux question:
Results 1 to 3 of 3
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2012
    Posts
    2

    Shared Memory Access Problem


    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, but not able to, when executed by a user?

    I should mention that both the server and client executables have been chmoded to 777.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,709
    This post was about 6 months ago. Do you still need help? If so, I am not sure what the flag "0666" for a flag means. In such cases, you should ALWAYS use symbolic constants such as SHM_NORESERVE, IPC_EXCL, etc.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Linux User
    Join Date
    Dec 2011
    Location
    Turtle Island West
    Posts
    460
    Quote Originally Posted by Rubberman View Post
    This post was about 6 months ago. Do you still need help? If so, I am not sure what the flag "0666" for a flag means. In such cases, you should ALWAYS use symbolic constants such as SHM_NORESERVE, IPC_EXCL, etc.
    Whatchu Talkin' bout Willis? Shm is deep magic.

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •