<br><br><div class="gmail_quote">On Wed, Jan 28, 2009 at 7:56 AM, Juraj Hercek <span dir="ltr"><<a href="mailto:juhe_haskell@hck.sk">juhe_haskell@hck.sk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hello people,<br>
<br>
I've recently tried this:<br>
<br>
$ uname -smpr<br>
Linux 2.6.28-ARCH x86_64 Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz<br>
$ ghci<br>
GHCi, version 6.10.1: <a href="http://www.haskell.org/ghc/" target="_blank">http://www.haskell.org/ghc/</a> :? for help<br>
Loading package ghc-prim ... linking ... done.<br>
Loading package integer ... linking ... done.<br>
Loading package base ... linking ... done.<br>
Prelude> a <- readFile "/sys/devices/system/cpu/online"<br>
Prelude> length a `seq` a<br>
"^CInterrupted.<br>
Prelude> writeFile "/tmp/test.txt" "12345\n"<br>
Prelude> b <- readFile "/tmp/test.txt"<br>
Prelude> length b `seq` b<br>
"12345\n"<br>
Prelude><br>
<br>
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.<br>
<br>
I tried also other machine:<br>
% uname -smpr<br>
Linux 2.6.28-ARCH i686 Intel(R) Pentium(R) 4 CPU 2.00GHz<br>
<br>
with the same effect. I didn't have this problem with ghc-6.8.2.<br>
<br>
Any idea?</blockquote><div><br></div><div>Well readFile is a lazy getContents:</div><div><br></div><div><span class="Apple-style-span" style="font-family: -webkit-sans-serif; font-size: 16px; ">The <tt style="font-size: 100%; "><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v%3AgetContents" style="color: rgb(0, 0, 224); text-decoration: none; ">getContents</a></tt> operation returns all user input as a single string,</span><br>
</div><div><br></div><div>so per the documentation reading the whole file is the documented behavior.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
<br>
-- Juraj<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br>