Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

148
Views
Location of /dev/shm on Mac OS X

I am working on a shared memory assignment on Mac OS X

    #define SHARED_OBJECT_PATH    "/my_shared_memory"

    fd = shm_open(SHARED_OBJECT_PATH, O_CREAT | O_EXCL | O_RDWR, S_IRWXU | S_IRWXG);
    if (fd < 0) {                                                         
        perror("In shm_open()");                                          
        exit(1);                                                          
    }

One of the small snippets in the program is the above.

When I compile and run the program a second time, I would get the error:

In shm_open(): File exists

I am assuming because I need to manually delete using rm [path_to]/my_shared_memory. I know on Linux, the default location is dev/shm, however, this path does not exist on Mac OS X.

Where is the location of my_shared_memory so I can delete it?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The simplest solution to your problem is not using

O_EXCL

if you don't want that behaviour.

Generally, shared memory objects do have a name, but it's not really a file name -- you can't generally delete them. It's good POSIX style to display them under /dev/shm, but this depends on your OS:

My best guess would be that you should read what man shm_open says on your machine.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!