linux - Show the list of running processes in C -
can suggest me system call retrieves current running processes? (i have write c function top)
i tried read proc/
folder not in case.
the only way on linux access /proc/
pseudo-file system. remember /proc/
files not "real" files on disk, i/o (i.e. reading /proc/
files) quite fast.
read proc(5) man page.
you use libprocps
reading /proc/
the ps
, top
(and htop
etc...) commands using /proc/
; if want use them inside program (which may bad idea) use popen(3) (to output) not system(3)
so running processes use readdir
on /proc/
, read /proc/*/stat
files, remembering status r
etc... etc...
Comments
Post a Comment