[Top][All Lists]

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

bug: dd copies a random number of bytes

From: Robb Matzke
Subject: bug: dd copies a random number of bytes
Date: Fri, 20 Feb 2009 23:50:59 -0500


I'm seeing some strange behavior with dd. The first two commands work and
report the expected number of records transferred (1024):

   dd if=/dev/zero bs=1MB count=1024 of=/dev/null
   dd bs=1MB count=1024 </dev/zero >/dev/null

But these report a random number of records, usually somewhere around 200,
but as few as 0 or as many as 1005:

   cat /dev/zero |dd bs=1MB count=1024 of=/dev/null
   cat /dev/null |dd bs=1MB count=1024 >/dev/null

An strace on dd shows that the last read/write pair both succeed and then dd
inexplicably closes both files.  None of the reads return zero or failure.
An strace on cat shows that its last write to stdout gets a sigpipe, so it
really is trying to send the data to dd and it's dd that's closing the pipe.

Replacing /dev/null with a real file exhibits the behavior one would expect.
Substituting some other I/O-counting command for dd works fine.

Any insights here?

Version info:
  gcc-4.1.2 x86_64
  linux-2.6.25 and 2.6.27
  (also tested on Ubuntu-8.10 i686 with same results)
Robb Matzke L-159   | Ph:  812-967-6325  | I/O, I/O, it's off to disk we go,
Lawrence Livermore  | Fax: 812-967-6326  | A petabyte to read or write,
National Laboratory | Hrs: 3am-11am PDT  | I/O, I/O.

reply via email to

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