M
Mark Seger
I have a script I've been running for some time that reads process data
from /proc/pid/stat. My outer loop open /proc and reads each entry with
readdir, opening that appropriate stat file and reading though it in
an inner loop as follow - the reason for the '99' is the same routine is
used to read other /proc structures beside process data:
for ($i=0; $i<99; $i++)
{
last if !($line=<PROC>);
print $line;
}
close PROC;
In any event, this should (and does) read a single line and then fall
through the loop. However, if I run this for a long time, it
occasionaly reads a second record which is not right! the contents of
that partial line look like the end of 'stat':
Opened /proc/8887/stat
8887 (sshd) R 1761 1761 1761 0 -1 64 153 54 231 43 19 62 0 0 15 0 0 0
484375023 6979584 449 4294967295 134512640 134784984 3221221808
3221202756 4294959106 0 0 4096 73728 0 0 0 17 0 0 0 19 62 0 0
9 62 0 0
thoughts?
-mark
from /proc/pid/stat. My outer loop open /proc and reads each entry with
readdir, opening that appropriate stat file and reading though it in
an inner loop as follow - the reason for the '99' is the same routine is
used to read other /proc structures beside process data:
for ($i=0; $i<99; $i++)
{
last if !($line=<PROC>);
print $line;
}
close PROC;
In any event, this should (and does) read a single line and then fall
through the loop. However, if I run this for a long time, it
occasionaly reads a second record which is not right! the contents of
that partial line look like the end of 'stat':
Opened /proc/8887/stat
8887 (sshd) R 1761 1761 1761 0 -1 64 153 54 231 43 19 62 0 0 15 0 0 0
484375023 6979584 449 4294967295 134512640 134784984 3221221808
3221202756 4294959106 0 0 4096 73728 0 0 0 17 0 0 0 19 62 0 0
9 62 0 0
thoughts?
-mark