Getting pid and other process information from /proc//status

后端 未结 1 1602
天命终不由人
天命终不由人 2021-01-24 09:44

I need to get some information (pid is just an example, i know its much easier to get it in many other ways) from /proc/PID/status

I have tried to do it th

1条回答
  •  我在风中等你
    2021-01-24 10:05

    The thing is /proc/[pid]/status is a text file. So your fread is copying text into the struct status - so everything will look like gibberish.

    You could read the status file line by line or you could use the /proc/[pid]/stat file which contains the same information on a single line (status is for human consumption while stat is for program consumtion). To get the process id (or any other information) you would just have to tokenize that single line.

    0 讨论(0)
提交回复
热议问题