Post details: read() me a bedtime story

11/19/05

Permalink 11:40:33 pm, Categories: Linux, 136 words   English (US)

read() me a bedtime story

A friend of mine posted a blog about read() calls and the maximum amount you can read. It got me interested too, so I did some tests as well.

First of all, I notice the read() manpage states (man 2 read):

If count is zero, read() returns zero and has no other results. If count is greater than SSIZE_MAX, the result is unspecified.

SSIZE_MAX on my Linux system is 2gig, or 2^31. I cannot read more than that. In fact, the largest buffer I can malloc is about 2934062847. Both malloc() and read() take types of size_t, type unsigned long, which is 4gig, or 2^32. But it seems read() cannot read more than 2^31. Hm, I know I can't use values greater than 2^32 on 32-bit systems, but I would expect read() to do up to 2^32 and not only 2^31.

Comments, Pingbacks:

No Comments/Pingbacks for this post yet...

Leave a comment:


Warning: touch() [function.touch]: Unable to create file /hsphere/local/home/valankar/viraj.org/_tmp/hn_captcha_counter.txt because No such file or directory in /hsphere/local/home/valankar/viraj.org/b2evolution/blogs/skins/hn_captcha.class.x1.php on line 209

Warning: touch() [function.touch]: Unable to create file /hsphere/local/home/valankar/viraj.org/_tmp/hn_captcha_counter.txt because No such file or directory in /hsphere/local/home/valankar/viraj.org/b2evolution/blogs/skins/hn_captcha.class.x1.php on line 209


An ERROR has occured!
Here you might send email-notification to webmaster or something like that.

Unable to safe captcha-image.