I need to recover all running processes using c ++ and under linux. But I don't find lib or corresponding functions.
I can't run a linux command such as "ps".
I need to recover all running processes using c ++ and under linux. But I don't find lib or corresponding functions.
I can't run a linux command such as "ps".
(I'm guessing that you need to inspect, scan, list, or discover processes; recovering processes is a difficult thing, read about application checkpointing)
You should consider using proc(5), that is the /proc/ filesystem (Linux specific).
The process of pid 1234 is described by the /proc/1234/ directory. Try ls /proc/$$/ in a terminal.
So you can explore processes by using appropriate calls (e.g. opendir(3), readdir(3), closedir(3), stat(2) etc....) on the /proc/ file tree (and this is what ps, top etc.. are using; check with strace(1) ...).
Beware that many files under /proc/ have a 0 size as given by stat(2) but are sequentially readable (a bit like a pipe). Try for example stat /proc/$$/status then cat /proc/$$/status. See also this.