How to get pointer of task_struct corresponding to a pid value.
Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
How to get pointer of task_struct corresponding to a pid value.
Hi Guys,
I have written a kernel module code.where I have list of pid (process ids) stored in a Singular link list. I want to know if processes corresponding to its pids is alive or killed.in order to meet this requirement I need pointer of task_struct corresponding to the pid.
Also if any one know about what is namespace in linux OS??
Well one method I can think of, not very efficient though, is to loop through all the task_structs comparing the pids. If the processes that you have are related to each other ,that is they have a common parent then it will be easier .
Is it possible if we could travel in task_struct. I have pid but not relevant to any other pid. i have just a value of pid ,can i get pointer of task_struct using that pid value only if yes help me please
find_task_by_pid will return a pointer to a task_struct,
though it is now deprecated, because with namespaces it
will return only the task in an initial namespace.
you can use task_by_pid_ns and pass it the namespace
where your pid resides.
Best thing to do is to find the handler for some function-call, in the source code of your particular distribution, that uses a PID as one of its inputs. Trace through the code to find out how it's used. Copy that example, and of course, "Google it."
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.