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

  • Home
  • SEARCH
  • 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 6646233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:23:29+00:00 2026-05-26T00:23:29+00:00

I have an issue attempting to access shared memory using mmap for complex types.

  • 0

I have an issue attempting to access shared memory using mmap for complex types.

So I allocate my memory as so in my parent process:

/* Create mmap file */
fid = open(TMP_FILE_NAME, O_RDWR | O_CREAT | O_EXCL, (mode_t) 0755);
if (fid < 0)
{
  printf("Bad Open of mmap file <%s>\n", TMP_FILE_NAME);
  die(-1);
}

/* Make mmap file Buffer Size */
status = ftruncate(fid, INPUT_BUFFER_SIZE); 
if (status)
{
    printf("Failed to ftruncate the file <%s>, status = %d\n", TMP_FILE_NAME, status);
    die(-1);
}

/* Initialize Shared Memory */
mmap_ptr = mmap((caddr_t) 0,
      INPUT_BUFFER_SIZE,        // Default Buffer Size
      PROT_WRITE | PROT_READ,   // R/W Permissions
      MAP_SHARED, // No file backing
      fid,  
      (off_t) 0);
if (mmap_ptr == MAP_FAILED)
{
    printf("Failed to perform mmap, Exiting\n");
    die(-1);
}

Now the Struct that I’m passing in memory to my child process is as follows:

/* Data structue for IPC */
typedef struct {
    int current_active_id;
    int consume_remaining;
    Queue buffer;
} input_buffer;

where Queue is a data structure class from the following:
http://www.idevelopment.info/data/Programming/data_structures/c/Queue/Queue.shtml

In my child process it’s okay when I do this, it returns the correct value:

printf("Got here... Shared Mem: %d\n", input_queue->consume_remaining);

but when I do something like:

IsEmpty(input_queue->buffer)

it crashes and in the code of the Queue it’s only doing this:

return Q->Size == 0;

Any help would be appreciated, thanks!!

  • 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-26T00:23:30+00:00Added an answer on May 26, 2026 at 12:23 am

    Queue is a pointer to struct QueueRecord, and should be allocated as such, presumably using the same shared memory segment. note that this should also be mapped at the same address in both parent and child, or you will not be able to dereference it.

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

Sidebar

Related Questions

I have an issue that is driving me a bit nuts: Using a UserProfileManager
We have an issue using the PEAR libraries on Windows from PHP . Pear
I have an issue with using AWK to simply remove a field from a
I am attempting to connect to an Access 2000 database file (*.mdb), but I
I am attempting to access a web service using SOAP through Perl and am
I'm encountering a strange issue when attempting to access a __block (block mutable) variable
I have a customer using the Access 97 runtime to support part of their
I am attempting to use the DELETE clause in MS Access and have an
I have created a JSON object in php using json_encode and am attempting to
I've just run into an issue when attempting to grab a custom View using

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.