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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:54:32+00:00 2026-05-31T16:54:32+00:00

According to man 5 proc , one can use the /proc filesystem to access

  • 0

According to man 5 proc, one can use the /proc filesystem to access the following information on Linux:

   /proc/[pid]/maps
          A file containing the currently mapped memory regions and their access
          permissions.

          The format is:

          address           perms offset  dev   inode   pathname
          08048000-08056000 r-xp 00000000 03:0c 64593   /usr/sbin/gpm
          08056000-08058000 rw-p 0000d000 03:0c 64593   /usr/sbin/gpm
          08058000-0805b000 rwxp 00000000 00:00 0
          40000000-40013000 r-xp 00000000 03:0c 4165    /lib/ld-2.2.4.so
          40013000-40015000 rw-p 00012000 03:0c 4165    /lib/ld-2.2.4.so
          4001f000-40135000 r-xp 00000000 03:0c 45494   /lib/libc-2.2.4.so
          40135000-4013e000 rw-p 00115000 03:0c 45494   /lib/libc-2.2.4.so
          4013e000-40142000 rw-p 00000000 00:00 0
          bffff000-c0000000 rwxp 00000000 00:00 0

          where "address" is the address space in the process that it occupies,
          "perms" is a set of permissions:

               r = read
               w = write
               x = execute
               s = shared
               p = private (copy on write)

          "offset" is the offset into the file/whatever, "dev" is the device
          (major:minor), and "inode" is the inode on that device.  0 indicates
          that no inode is associated with the memory region, as the case would
          be with BSS (uninitialized data).

          Under Linux 2.0 there is no field giving pathname.

I don’t really want to be writing text parsing code in C; I’d rather just make calls to the OS and read the information directly into structures. I looked in /usr/include/linux to see if there was an obvious structure with APIs, but didn’t see anything.

So, two part question:

  1. Can this be considered a “bad idea”? That is, should user programs just bite the bullet and read text from /proc in case the kernel interfaces change? If so, is there an accepted “best practice” for reading from /proc using C? (fscanf()? Regular expressions?)
  2. How would I go about finding the documentation for the kernel interfaces (assuming they exist) which would allow me to directly read this data? (Is the kernel source itself the best place to start? If so, where in the kernel source should I look?) Bonus points if you know what interface can provide the /proc/[pid]/maps data specifically. =)
  • 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-31T16:54:33+00:00Added an answer on May 31, 2026 at 4:54 pm

    I think for a perl or shell script it’s perfectly fine to read and parse the /proc/ data. In a C program, if robustness is required, I would use a kernel (probably a sysctl) interface.

    Turns out that the procps-bundled pmap implementation parses /proc/PID/maps files line-by-line as follows (see one_proc() function):

    sscanf(mapbuf,"%"KLF"x-%"KLF"x %31s %Lx %x:%x %Lu", &start, &end, flags, &file_offset, &dev_major, &dev_minor, &inode);
    

    EDIT: Original version of my answer showed a way to parse data on shared memory segments only, not all mapped memory segments as the OP desired.

    I believe ipcs -m will give you the same data for multiple processes. So the answer to your second question is that you should read the ipcs code: (e.g BSD version, Linux version):

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

Sidebar

Related Questions

According to what I have found so far, I can use the following code:
According to the man page for pbpaste , -Prefer {txt | rtf | ps}
According to the answers to this question, I cannot embed a file version in
Real simple question. According to my man-page, these two will do the same: time_t
Given the configuration in /proc/sys/kernel/core_pattern set to /cores/core.%e.%p , core dumps are named according
So, I'm a bit stymied. According to man 3 printf on my system, the
I changed ffmpeg.c according following link: http://www.roman10.net/how-to-port-ffmpeg-the-program-to-androidideas-and-thoughts/ He said the change main () to
According to Wikipedia, an embarrassingly parallel problem is one for which little or no
According to this article from Herb Sutter, one should always pick Class Specializing over
According to my class notes, you can allocate an array in C++ like int

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.