I've got an odd problem that I am trying to track down...
Kernel is 2.6.18 x86_64 SMP SUSE Linux.
We have some monitoring programs that watch processes. They do this
by looking in /proc/<pid>/stat and finding the SID, memory size,
etc... To do this, we use fopen, fscanf. In the case where the fscanf
fails, we do a rewind and fgets into a buffer so we can figure out
what was in the file (to improve debugging).
Occasionally, we see a successful fopen of the stat file, but the file
It's been a while since I've looked at the proc fs code, but what I
remember is that if the stat file is able to be opened, there will
always be data in it. It will never be empty. If the process is gone
(cleaned up, not zombie) then the status would be "X".
Am I missing something here? Is there a case where the fopen would be
successful, yet the file has no contents?
I suspect a timing issue, but can't figure out what it would be.
I would add something like system("cat /proc/<pid>/stat > /some_log_dir_path/log_<_filename_timestamp>"); , just to ensure it is not bug in your code, and the file is really empty.
|All times are GMT -5. The time now is 01:21 AM.|