Quantcast
Channel: Active questions tagged linux-kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 12391

looping over a process's parents, Linux kernel

$
0
0

The following code loops over the ancestors of curr_task, all the way to the swapper process (i.e the "most distant" ancestor of any Linux process), where it stops because swapper == swapper->parent.

while (curr_task != curr_task->parent)       ...get curr_task info       curr_task = curr_task->parent

The problem is I also want to get the swapper process's info. There are a couple obvious ways to do this (eg goto statement after the while loop, or a single if statement after the loop that gets the swapper info). However, these obvious solutions seems fairly inelegant, and so I'm looking for a more concise solution that doesn't involve the much-maligned goto or copy/pasting code.


Viewing all articles
Browse latest Browse all 12391

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>