Is there a way to tell if the contents of the stat/status file for a process has changed, without opening it?
有没有办法判断进程的stat / status文件的内容是否已更改,而不打开它?
I was thinking you could just check the last-modified time, however the timestamp almost never changes. I coded this using stat(), however it did not return the desired effect (same with ls under the shell.)
我以为你可以检查最后修改的时间,但时间戳几乎不会改变。我使用stat()对此进行编码,但是它没有返回所需的效果(与shell下的ls相同)。
It's quite possible I'm looking about this the wrong way. I'm just wanting to be able to constantly probe the stat values of the process, similar to the top command (and no, taking data from top is nowhere near acceptable.)
我很有可能以错误的方式看待这个问题。我只是想能够不断探测过程的统计值,类似于top命令(并且不,从顶部获取数据远不可接受。)
1 个解决方案
#1
1
You can't do this using any normal I/O operations on stat/status because they're not true files.
您不能使用stat / status上的任何常规I / O操作来执行此操作,因为它们不是真正的文件。
https://unix.stackexchange.com/questions/90627/notify-of-changes-on-a-file-under-proc explains why you can't work with these files like with regular files.
https://unix.stackexchange.com/questions/90627/notify-of-changes-on-a-file-under-proc解释了为什么你不能使用常规文件这些文件。
#1
1
You can't do this using any normal I/O operations on stat/status because they're not true files.
您不能使用stat / status上的任何常规I / O操作来执行此操作,因为它们不是真正的文件。
https://unix.stackexchange.com/questions/90627/notify-of-changes-on-a-file-under-proc explains why you can't work with these files like with regular files.
https://unix.stackexchange.com/questions/90627/notify-of-changes-on-a-file-under-proc解释了为什么你不能使用常规文件这些文件。