
On Wed, Jan 28, 2009 at 7:56 AM, Juraj Hercek
Hello people,
I've recently tried this:
$ uname -smpr Linux 2.6.28-ARCH x86_64 Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz $ ghci GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude> a <- readFile "/sys/devices/system/cpu/online" Prelude> length a `seq` a "^CInterrupted. Prelude> writeFile "/tmp/test.txt" "12345\n" Prelude> b <- readFile "/tmp/test.txt" Prelude> length b `seq` b "12345\n" Prelude>
The main problem is the "C^Interrupted." above. The input doesn't get read out till the end of the file for some reason when dealing with files in /sys directory (tried also others: /sys/devices/plaform/coretemp.0/temp1_input or /sys/devices/system/cpu/cpu0/cpufreq/cpufreq_cur_freq). Sometimes, the string from file in /sys gets read (with a slow delay), but most of the times it didn't. Everything works fine for a file in /tmp. Cat-ing files from shell works perfectly in /sys and /tmp.
I tried also other machine: % uname -smpr Linux 2.6.28-ARCH i686 Intel(R) Pentium(R) 4 CPU 2.00GHz
with the same effect. I didn't have this problem with ghc-6.8.2.
Any idea?
Well readFile is a lazy getContents: The getContentshttp://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v%3AgetC... operation returns all user input as a single string, so per the documentation reading the whole file is the documented behavior.
-- Juraj _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe