How to get a list of the running processes in the system?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
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.
How to get a list of the running processes in the system?
Hello, I'd like to programatically get a list of the running processes on my system. I wouldn't like the approach of running "ps" with some parameters and then parse the output. I'm developing a Java application to monitor some things, and one of them is the running processes on the system, and I intend to use JNI to get them. On windows I have some C++ code which does the trick, but I really didn't find any example of code to do this on linux. If you have any suggestions about any programming language they are welcome. Thank you.
try ls /proc compare folder names with the output of ps and you can see that each pid has a folder named pid with more info inside. I have seen a good explanation of this and other system programming stuff in the book "advanced programming in the unix environment"
try ls /proc compare folder names with the output of ps and you can see that each pid has a folder named pid with more info inside. I have seen a good explanation of this and other system programming stuff in the book "advanced programming in the unix environment"
Originally Posted by http://en.wikipedia.org/wiki/Procfs
procfs is supported under:
* Solaris
* BSD
* Linux (which extends it to non-process-related data)
* IBM AIX (operating system) (which bases its implementation on Linux to improve compatibility)
Have a look at a busybox' implementation of ps based on proc. There's even a function called procps_scan (./libbb/procps.c). That should save you a lot of time.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.