Why dd finishes instantly when pipelining to cat?
- by agsamek
I start bash on Cygwin and type:
dd if=/dev/zero | cat /dev/null
It finishes instantly. When I type:
dd if=/dev/zero > /dev/null
it runs as expected and I can issue
killall -USR1 dd
to see the progress. Why does the former invocation finishes instantly? Is it the same on a Linux box?
* Explanation why I asked such stupid question and possibly not so stupid question
I was compressing hdd images and some were compressed incorrectly. I ended up with the following script showing the problem:
while sleep 1 ; do killall -v -USR1 dd ; done &
dd if=/dev/zero bs=5000000 count=200 | gzip -c | gzip -cd | wc -c
Wc should write 1000000000 at the end. The problem is that it does not on my machine:
bash-3.2$ dd if=/dev/zero bs=5000000 count=200 | gzip -c | gzip -cd | wc -c
13+0 records in
12+0 records out
60000000 bytes (60 MB) copied, 0.834 s, 71.9 MB/s
27+0 records in
26+0 records out
130000000 bytes (130 MB) copied, 1.822 s, 71.4 MB/s
200+0 records in
200+0 records out
1000000000 bytes (1.0 GB) copied, 13.231 s, 75.6 MB/s
1005856128
Is it a bug or am I doing something wrong once again?