Reputation: 43
For a CPP application in linux, I need the running processes list, their PID , The port they are running on, and the location of the .exe file where it is started from.
I can use PS command, But I want it in a CPP application. Using System command and parsing the output is not recommended.
Does Linux store these information somewhere from where I can read or is there some native API's which I can make use of like win32 api's in windows.
Upvotes: 3
Views: 13997
Reputation: 7374
You can use libproc-dev
.
The /proc interface provides access to the state of each user-level process and thread also known as lightweight process or lwp in the system. It also provides the ability to control such processes and threads. It is a low-level interface.
The libproc library provides a higher-level interface to the features of the /proc interface as well as access to information such as symbol tables which is necessary for the examination and control of processes and threads. For more information, see the proc(5) man page.
Take a look at some examples
Upvotes: 3