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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:14:42+00:00 2026-06-11T03:14:42+00:00

Perhaps I’m just going about this wrong. I have a Linux module (Ubuntu 12.04)

  • 0

Perhaps I’m just going about this wrong.

I have a Linux module (Ubuntu 12.04) that needs to gather information about current processes such as the number of files each process has open, and so on. I’d thought that the best way to do this would be for the module to read /proc and for each process represented there look in the /proc subdirectory for the information it wants.

Clearly my module can’t call opendir/readdir. I’d thought that there was a proc_readdir() that I could use from kernel space but I can’t seem to find any information on it.

Am I missing something? Is there a better way for the module to gather process information? If it is proc_readdir() then where can I find some example of that?

  • 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-11T03:14:43+00:00Added an answer on June 11, 2026 at 3:14 am

    If you’re just moving to kernel-space programming it may take you quite a while to get used to doing things the right way. /proc is just an interface to the kernel-space data structures, and an inconvenient one at that (what will all the ASCII). As you’re in the kernel you can access the data you want directly.

    You should be looking at processes task_struct entries (see http://lxr.linux.no/linux+v3.5.3/include/linux/sched.h). If you want to iterate over each process try something like the following:

    struct task_struct *task;
    for_each_process(task) {
        printk(KERN_INFO "Process %i is named %s\n", task->pid, task->comm); 
    }
    

    You can also find a specific task by pid using find_task_by_pid_ns, but you’ll have to worry about pid namespaces. There’s also get_current, which will find you the currently executing task.

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

Sidebar

Related Questions

Perhaps I'm going about this all wrong (and please tell me if I am),
Perhaps I am going about this the wrong way. Let me know Using Swing
Perhaps I'm going about this the wrong way, but I'm using HXT to read
Perhaps i am being stupid by asking this just now, but... I notice that
Perhaps this is my lack of understanding, but I would have assumed that doing
Perhaps any of you can help me with this anoying problem. I have long
Perhaps I am getting rusty (have been writing in Python recently). Why does this
Perhaps the title is worded incorrectly. I have a global Busy Indicator that works
Perhaps this is nitpicky, but I have to ask. I'm using Nokogiri to parse
Perhaps this is just my background in more imperative programming, but I like having

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.