[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: read() builtin doesnt read integer value /proc files (but bashs
From:       Ralf Friedl <Ralf.Friedl () online ! de>
Date:       2010-12-19 14:59:19
Message-ID: 4D0E1DC7.3070506 () online ! de
[Download RAW message or body]

Cristian Ionescu-Idbohrn wrote:
> On Sun, 19 Dec 2010, Denys Vlasenko wrote:
>   
>> The fix is hard. Consider that read should work properly here:
>>
>> exec </proc/some/file
>> read line
>> cat
>>
>> If read "reads ahead" 128 bytes, but finds '\n' after 5th byte,
>> how can it "roll back" so that cat starts reading at the right
>> position?
>>     
>
> Seems bash somehow manages to deliver what's expected:
>   
The way bash does it is to do an lseek to the right position after the 
read, after verifying that lseek is possible. Of course this doesn't 
necessarily work for proc files.

ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbfa7ff48) = -1 ENOTTY 
(Inappropriate ioctl for device)
_llseek(0, 0, [0], SEEK_CUR)            = 0
read(0, "\nWelcome to SuSE Linux 9.2 (i586) - Kernel \\r (\\l).\n\n\n", 
128) = 54
_llseek(0, -53, [1], SEEK_CUR)          = 0

Ralf
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic