В Sun, 18 Sep 2011 22:02:51 +0200
Gert Doering <g...@greenie.muc.de> пишет:

> Hi,
> 
> On Sun, Sep 18, 2011 at 10:58:23PM +0400, Alexander Gordeev wrote:
> > BTW you shouldn't even expect to read() 6 bytes from file at once.
> 
> For normal files, read() will never read less than requested, unless you
> hit an error or eof.

Right. But then user decides to make a named pipe instead of a normal
file, then the program fails. I meant something like this.

> > $ strace -f -e trace=read,write sh -c 'dd if=/dev/urandom bs=1 count=6
> > | cat > /dev/null'
> 
> /dev/urandom is not a *file*...
> 
> > cat tries to read 32768 but gets 1 byte on every read.
> 
> ... and cat does not read from /dev/urandom in the first place here, but 
> from the pipe from dd.

It was primarily an example of read() from pipe behaviour.
/dev/urandom was chosen randomly. :)

-- 
  Alexander

Attachment: signature.asc
Description: PGP signature

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to