答复: [Haskell-cafe] How to do this in FP way?
dons at galois.com
Tue Jun 17 11:48:58 EDT 2008
> OK. Here it is.
> I want to make a monitor tool for linux. It runs for a long time, and give
> out a certain process's io stat per second. The way I get io stat is to read
> from /proc/pid/io. But the data in this file is a total, I need to read it
> first, then next second, read it again, and shows the difference, and go on.
> So, what is your idea?
main = go 0
go st = forever $ do
n <- read `fmap` readFile "/proc/pid/io"
print (n - st) -- display difference
More information about the Haskell-Cafe