# HG changeset patch # User Heiko Schlittermann (JUMPER) # Date 1351972909 -3600 # Node ID 491292dcec7f9d0f5da7c12842e5502c82d4f028 works for me diff -r 000000000000 -r 491292dcec7f .hgignore diff -r 000000000000 -r 491292dcec7f .perltidyrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.perltidyrc Sat Nov 03 21:01:49 2012 +0100 @@ -0,0 +1,3 @@ +--paren-tightness=2 +--square-bracket-tightness=2 +--nospace-for-semicolon diff -r 000000000000 -r 491292dcec7f pdd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pdd Sat Nov 03 21:01:49 2012 +0100 @@ -0,0 +1,97 @@ +#!/usr/bin/perl + +use 5.010; +use strict; +use warnings; +use threads; + +sub dd; +sub timer; +sub main; + +MAIN: { + my $dd; + + $SIG{INT} = sub { + if (defined $dd) { + warn "Got $_[0], going to kill dd(pid:$dd)\n"; + kill $_[0] => $dd; + } + }; + + say "[dd @ARGV]"; + + my ($if) = map /^if=(.*)/ => @ARGV; + my $ifsize = -s (defined $if ? $if : \*STDIN); + + $dd = dd @ARGV; + + # the timer runs in its own thread, there it will + # send a USR1 every now and then to the $dd process + + my $timer = threads->create(\&timer, $dd); + + printf "%8s %8s %8s %15s %3s\n", + "time", "MB", "M/s", "speed", "done"; + + my ($speed, $time, $size) = (0, 0, 0); + my @output = (); + while (
) { + push @output, $_; + + /^(?\d+) + \s+bytes.*copied,\s+ + (?