bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#8490: dd reads random number of records from pipes - named or otherw


From: John Reiser
Subject: bug#8490: dd reads random number of records from pipes - named or otherwise - coreutils 8.9
Date: Wed, 13 Apr 2011 08:02:06 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Thunderbird/3.1.9

> dd, when reading from stdin or from a named pipe sometimes (but not always) 
> reads a random number of records a bit less then what it should.

> yes|dd bs=1000 count=1000|wc -c
> cat /dev/zero |dd bs=1000 count=1000 |wc -c

dd does "read(fd,buf,bs)" for 'count' times, and writes whatever it gets each 
time.
If the operating system does not deliver 'bs' bytes each time, then the total 
output
will be less than bs*count bytes.  Because neither /usr/bin/yes nor /dev/zero
generates records with a blocksize of 1000 bytes (nor divisible by 1000 bytes)
then you are at the mercy of multiprocessing delays and pipe buffering.  read()
on a pipe waits only for non-empty, not necessarily for the size requested.

-- 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]