read() called twice for /proc files

Tim Hockin (
Mon, 24 Sep 2001 18:34:14 -0700

woops! sent too early!

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

What if the proc generic stuff used file->private_data as an EOF flag. It
seems really bizarre that the read loop loops until return 0 or eof is
set. We promptly throw away the EOF information that the read() handler

Would it break anything? Is there something I am not seeing in the larger

Tim Hockin
Systems Software Engineer
Sun Microsystems, Cobalt Server Appliances
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at