I read from / proc / pid / task / stat to track CPU usage in the thread. fopen on / proc / pic / task / stat fget line from sscanf stream in line
I am having problems updating stream buffers. If I update 1024 characters, if updated, but if I create 128 characters, it will never be updated, and I always get the same statistics. I rewind the stream before reading and tried fsync.
I do this very often, so I do not want to reopen the file every time. What is the right way to do this?
Not every program has the benefits of using buffered I / O.
, , read(2) 1. , :
read(2)
, , . , , cp(2) , -.
cp(2)
1. open(2), read(2), lseek(2) close(2).2. , , , , , - "" fflush(stdin), - , , fflush() C99 on , , .
open(2)
lseek(2)
close(2)
fflush(stdin)
fflush()