Linux - Kernel This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
06-12-2012, 12:45 PM
|
#1
|
LQ Newbie
Registered: Jun 2012
Posts: 4
Rep:
|
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??
Please help me.
Regards
Rach D
|
|
|
06-13-2012, 12:45 AM
|
#2
|
Member
Registered: Feb 2009
Posts: 347
Rep:
|
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 .
Here is an example of how you can iterate over processes.
http://tuxthink.blogspot.in/2011/03/...roc-entry.html
|
|
1 members found this post helpful.
|
06-13-2012, 01:00 AM
|
#3
|
LQ Newbie
Registered: Jun 2012
Posts: 4
Original Poster
Rep:
|
Thanks !! for the reply
Hey
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
Regards
Rach D
|
|
|
06-13-2012, 05:22 AM
|
#4
|
LQ Newbie
Registered: Jun 2012
Posts: 4
Original Poster
Rep:
|
I found a way find_task_by_pid_ns()
Hi All,
Can any one let me know what that function working and how to use it to get task_struct pointer please help me !!!
Regards
Rach D
|
|
|
06-14-2012, 11:48 AM
|
#5
|
LQ Newbie
Registered: May 2011
Location: Vienna
Distribution: gentoo
Posts: 10
Rep:
|
find_task_by_pid ( pid )
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.
regards, michael
|
|
|
06-26-2012, 12:43 PM
|
#6
|
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,861
|
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."
|
|
|
All times are GMT -5. The time now is 10:08 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|