read() called twice for /proc files
Is there a general solution to the case of read() being called minimum twice for a file in /proc? I have a small file in /proc, whose data takes a fair time to generate. My read() handler gets called once for the data, and once so I can return 0 to terminate read().
This results in the actual read taking twice as long. Perhaps I am missing something...
Signature · 4 lines
Tim Hockin Systems Software Engineer Sun Microsystems, Cobalt Server Appliances [email protected]
From: Tim Hockin <[email protected]>
Date: Mon, 24 Sep 2001 18:29:49 -0700
This results in the actual read taking twice as long. Perhaps I am missing something...
EOF isn't known until you return the zero. You can watch the loff_t arg to the read operation to see if it is at the end, and if so just avoid retouching the device or whatever and go straight to returning 0.
Franks a lot,
David S. Miller
[email protected]