Display all process using a posix function

前端 未结 4 955
一生所求
一生所求 2020-12-06 21:38

I am trying to display currently running process in Ubuntu.

Right now I am using system() function to print running process in the terminal. Code:

sy         


        
4条回答
  •  爱一瞬间的悲伤
    2020-12-06 21:40

    As far as I know does ps on Linux internally loop over the directories (corresponding to process ids) found under /proc. So I think there is no single function doing that, you'd have to loop over the subdirectories of /proc yourself (using more generic POSIX functions such as readdir etc.).

提交回复
热议问题