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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:38:11+00:00 2026-05-12T16:38:11+00:00

I am trying to traverse a task_struct’s children in the linux kernel and get

  • 0

I am trying to traverse a task_struct’s children in the linux kernel and get information from the children. I’m having problems with all the information, so let’s just keep it at the getting the pid for simplicity.

This is the relavant part of my code.

struct list_head * p;
struct task_struct ts, *tsk;
pid_t tmp_pid;
INIT_LIST_HEAD(&ts.children);

current = tsk;

list_for_each(p, &(tsk->children)){
     ts = *list_entry(p, struct task_struct, children);
     tmp_pid = ts.pid;
     printk("the pid is %d\n", tmp_pid);
}

I think the problem is with list_entry but I don’t know how to fix it, all the examples I can find seem to be calling it the same way.

This should print out all the child PIDs, instead I always get the same number -17…. it’s on the order of 10^9 or 10^11.

can anyone help me out here? compiling takes about 30 minutes, so trying a log of different things isn’t really an option.

  • 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-12T16:38:12+00:00Added an answer on May 12, 2026 at 4:38 pm

    You should be using

    list_entry(p, struct task_struct, sibling);
    

    Not

    list_entry(p, struct task_struct, children);
    

    Ho and also, you should lock the tasklist_lock when you go through the childrens.

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

Sidebar

Related Questions

I'm a newbie to selenium. I'm trying to traverse all the elements in a
I'm trying to find information on different ways to traverse an object tree in
I am trying to traverse all directories under the current directory using a shell
So I am trying to traverse a directory and find all the instances of
I'm having a real case of the monday's. I'm trying to traverse a table
Am trying to parse the RSS feed from www.ted.com/talks/rss, I can access all normal
I'm trying to traverse through all the subdirectories of the current directory in Perl,
I am trying to use the FindFirstFile function to traverse through all of my
I'm new to jQuery, coming from prototype. I'm trying to traverse within a form
i am trying to traverse a given directory and create a list of files

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.