Is there a way to tell if the contents of the stat/status file for a process has changed, without opening it?

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.)

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.)

有帮助吗?

解决方案

You can't do this using any normal I/O operations on stat/status because they're not true files.

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top