Voelker, Bernhard wrote: > Pádraig wrote: >> Yep I think so. Moving just the install_signal_handlers() to the top, > > can we expect this to happen in one of the next releases? > >> p.s. I'm still unsure as to why open(O_TRUNC) takes "a while". >> Perhaps there is a trunc=paranoid mount option I'm unaware of >> that actually writes zeros when truncating a file. > > I guess this depends on the filesystem type. E.g. on another Solaris10 > box with UFS `dd if=/dev/zero of=$HOME/x bs=1G count=10` takes > a rather good ~1.5min while the subsequent open(O_TRUNC) then > takes ~6sec. I don't think zeroes are written there ;-)
Thanks for the clarification. I guess the file systems need time to deallocate all the blocks. Right so the attached seems to address the issue and passes all tests. I don't see much problem with adding this to the release we're trying to complete this week. cheers, Pádraig.
>From 2e4fbc9f1da8d2041f9ea0abd65c5213954f4255 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?P=C3=A1draig=20Brady?= <p...@draigbrady.com> Date: Thu, 13 Aug 2009 14:37:43 +0100 Subject: [PATCH] dd: fix a signal handling race * src/dd.c (main): Install the signal handlers at startup rather than just before the copy starts. In this way signals received before the copy (like during a slow truncate for e.g.) will be deferred and handled consistently. * THANKS: Add Bernhard's email address. * NEWS: Mention the fix. Reported by Bernhard Voelker. --- NEWS | 3 +++ THANKS | 1 + src/dd.c | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 6df0d65..a88546d 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,9 @@ GNU coreutils NEWS -*- outline -*- dd's oflag=direct option now works even when the size of the input is not a multiple of e.g., 512 bytes. + dd now handles signals consistently even when they're received + before data copying has started. + install runs faster again with SELinux enabled [introduced in coreutils-7.0] diff --git a/THANKS b/THANKS index d3541ce..bd078db 100644 --- a/THANKS +++ b/THANKS @@ -75,6 +75,7 @@ Bernd Melchers melch...@cis.fu-berlin.de Bernhard Baehr bernhard.ba...@gmx.de Bernhard Gabler bernh...@uni-koblenz.de Bernhard Rosenkraenzer b...@redhat.de +Bernhard Voelker bernhard.voel...@siemens-enterprise.com Bert Deknuydt bert.deknu...@esat.kuleuven.ac.be Bert Wesarg bert.wes...@googlemail.com Bill Peters pet...@gaffel.as.arizona.edu diff --git a/src/dd.c b/src/dd.c index d9e4c85..30bd808 100644 --- a/src/dd.c +++ b/src/dd.c @@ -1828,6 +1828,8 @@ main (int argc, char **argv) int exit_status; off_t offset; + install_signal_handlers (); + initialize_main (&argc, &argv); set_program_name (argv[0]); setlocale (LC_ALL, ""); @@ -1928,8 +1930,6 @@ main (int argc, char **argv) } } - install_signal_handlers (); - start_time = gethrxtime (); exit_status = dd_copy (); -- 1.6.2.5