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 6601401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:44:52+00:00 2026-05-25T18:44:52+00:00

I am using the combination of shm_open() and mmap() to create a shared memory

  • 0

I am using the combination of shm_open() and mmap() to create a shared memory segment for IPC. What I’m wondering is how the backing files (in /dev/shm in my system, Linux kernel 2.6.31) are cleaned up.

My questions are threefold:

1) Is it the process’s responsibility to unlink the files upon termination? If so, what if the process dies before it unlinks them?

2) Since I suspect the answer to #1 is “yes, it’s the program’s responsibility”, is it considered “good practice” for my program to remove any stale files it notices before creating a new one, in case previous instances died uncleanly?

3) Is there a way to ask the kernel to remove the backing file after the last process unmaps the memory? I am thinking of something similar to shmctl(id, IPC_RMID, ...) in SysV style shared memory.

  • 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-05-25T18:44:53+00:00Added an answer on May 25, 2026 at 6:44 pm

    The answers are as following:

    1. Yes, it is the program’s responsibility, although it may be possible to ensure cleanup, see my answer to 3.

    2. You could remove the stale files, You could also just use the existing shared memory object (which I assume you were going to recreate anyway).

    3. If you know that no other users for the shared section will exist after it is initially created, you can use shm_unlink right after mapping your shared memory. The memory region will be deallocated once all users unmap (and close) it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a simple mouseover effect using a combination of mouseover,
I'm trying to create an installer, using a combination of fwrite and forms. Here's
My company develop web apps using combination of mod_perl, axkit and apache. We have
I'm currently using a combination of CSS and Div tags to achieve rounded corners
I'm using the combination of json_encode (PHP) and JSON.parser (Javascript from json.org) for passing
In the application I'm writing using a combination of development environments and languages, I
I am trying to make a search function using the combination of DOM, PHP
All these years i have been successfully using EnumServicesStatus in combination with OpenScManager (with
Usually Flash and Flex applications are embedded on in HTML using either a combination
How do I pass a certain key combination to a spawned/child process using the

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.