Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8360731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:32:18+00:00 2026-06-09T11:32:18+00:00

I’m trying to create a shared memory which will be used by several processes,

  • 0

I’m trying to create a shared memory which will be used by several processes, which will not necessarily be started by the same user, so I create the segment with the following line:

fd = shm_open(SHARE_MEM_NAME,O_RDWR | O_CREAT,0606);

however, when I check out the permissions of the file created in /dev/shm they are:

-rw----r-- 1 lmccauslin lmccauslin 1784 2012-08-10 17:11 /dev/shm/CubeConfigShare
not -rw----rw- as I’d expected.

the permissions for /dev/shm are lrwxrwxrwx.

The exact same thing happens with the semaphore created similarly.

kernel version: 3.0.0-23-generic

glibc version: EGLIBC 2.13-20ubuntu5.1

Anyone got any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:32:19+00:00Added an answer on June 9, 2026 at 11:32 am

    It’s probably umask.

    Citing the manpage of shm_open:

       O_CREAT    Create  the  shared memory object if it does not exist.  The user and
                  group ownership of the object are taken from the corresponding effec‐
                  tive IDs of the calling process, and the object's permission bits are
                  set according to the low-order 9 bits of mode, except that those bits
                  set in the process file mode creation mask (see umask(2)) are cleared
                  for the new object.  A set of macro constants which can  be  used  to
                  define  mode  is  listed  in open(2).  (Symbolic definitions of these
                  constants can be obtained by including <sys/stat.h>.)
    

    So, in order to allow creating files which are world-writable, you’d need to set an umask permitting it, for example:

    umask(0);
    

    Set like this, umask won’t affect any permissions on created files anymore. However, you should note that if you will then create another file without specifying permissions explicitly, it will be world-writable as well.

    Thus, you may want to clear the umask only temporarily, and then restore it:

    #include <sys/types.h>
    #include <sys/stat.h>
    
    ...
    
    void yourfunc()
    {
        // store old
        mode_t old_umask = umask(0);
    
        int fd = shm_open(SHARE_MEM_NAME,O_RDWR | O_CREAT,0606);
    
        // restore old
        umask(old_umask);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I'm trying to select an H1 element which is the second-child in its group
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.