LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-19-2007, 07:19 AM   #1
zahadumy
Member
 
Registered: May 2005
Location: Cluj, Romania
Distribution: Fedora Core 6
Posts: 226

Rep: Reputation: 31
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.
 
Old 03-19-2007, 07:42 AM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
You could download the source of ps and see how that program does it.
 
Old 03-19-2007, 07:51 AM   #3
santana
Member
 
Registered: Sep 2004
Distribution: FC, ubuntu, OpenSuse
Posts: 112

Rep: Reputation: 16
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"
 
Old 03-19-2007, 08:04 AM   #4
zahadumy
Member
 
Registered: May 2005
Location: Cluj, Romania
Distribution: Fedora Core 6
Posts: 226

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by matthewg42
You could download the source of ps and see how that program does it.
You do have a point
 
Old 03-19-2007, 08:05 AM   #5
zahadumy
Member
 
Registered: May 2005
Location: Cluj, Romania
Distribution: Fedora Core 6
Posts: 226

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by santana
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"
Does this actually work on any distribution?
 
Old 03-19-2007, 08:07 AM   #6
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
Not all OS :
Quote:
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)
 
Old 03-19-2007, 08:09 AM   #7
zahadumy
Member
 
Registered: May 2005
Location: Cluj, Romania
Distribution: Fedora Core 6
Posts: 226

Original Poster
Rep: Reputation: 31
Oka... thank you guys.
 
Old 03-19-2007, 08:27 AM   #8
krizzz
Member
 
Registered: Oct 2004
Location: NY
Distribution: Slackware
Posts: 200

Rep: Reputation: 30
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Limitations of System Processes and Oracle Processes in RHEL AS3.0 sathyguy Linux - Enterprise 0 03-02-2007 11:52 PM
how to get a list of child processes? Thinking Programming 2 01-19-2006 07:42 AM
Command to list all running processes GSX Linux - General 4 02-23-2005 03:42 AM
dual processor system=more running processes? plisken Linux - Hardware 0 12-09-2004 03:48 PM
How to list all running processes? thrix Linux - Software 2 01-21-2004 12:43 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration