bug-coreutils
[Top][All Lists]
Advanced

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

Re: dd or other bug?


From: Pádraig Brady
Subject: Re: dd or other bug?
Date: Wed, 14 Mar 2007 13:46:00 +0000
User-agent: Thunderbird 1.5.0.8 (X11/20061116)

qm <Brad Allen wrote:
> I don't have time to complete this right now; putting
> |bfr inbetween the two fixes it and it makes my script work.
> If I have time I can do this later.
> 
> Given the following test file named "test", whose
> contents and size do not matter if size is greater than
> 1023, then we get:
> 
> while true; do dd if=test bs=1023 skip=1 2> /dev/null |
> dd bs=32768 count=1  2>/dev/null|wc -c; done
> 
> the output is:
> 
> sometimes 1023, sometimes greater.
> 
> It should always be equal to the size of the file-1023 or 32768,
> whichever is smaller.

I can confirm this behaviour (after waiting for a few mins) by doing:

dd bs=31023 if=/dev/zero of=test.dd count=1
(while true; do dd if=test.dd bs=1023 skip=1 2> /dev/null | dd bs=32768 count=1 
 2>/dev/null|wc -c; done) | uniq

What I think is happening is due to the buffering
in the pipes in the kernel (between the 2 dd processes).
The second dd process does a read(stdin,buf,32768),
but all that data may not be available to the second
process in the pipe buffer for many reasons.

dd does not issue another read() request to fill the input buffer,
before proceeding with the write(). I'm not sure why it does this.

Pádraig.




reply via email to

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