Matty wrote: > On 4/5/07, James Carlson <james.d.carlson at sun.com> wrote: >> Darren J Moffat writes: >> > Matty wrote: >> > > Howdy, >> > > >> > > Most Linux and BSD distributions ship with a version of dd that >> > > displays the status of a copy operation when a SIGUSR1 signal is >> > > received. For some reason /usr/bin/dd on Solaris hosts doesn't >> contain >> > > this capability, and I would like to add it. After reading through >> the >> > > source code for dd.c, it looks like adding this support would be as >> > > simple as installing a signal handler for SIGUSR1, and having it call >> > > the function stats. I am attaching code (which I copied from the dd >> > > that ships with Fedora Core Linux) >> > >> > What license is that dd code you copied under ? >> > >> > You can't just copy code like that without considering the licenses. >> >> Indeed. That's GPLv2 code, which would require OpenSolaris dd to >> become GPLv2 as well. >> >> That can't be done. Either start provably from scratch or use >> software under a compatible license. > > Your absolutely right, and Stephen Hahn was nice enough to point this > out in an email last night. Since the existing code uses signal to > register the SIGINT signal handler (I reckon the issues Bart mentioned > are minimized since it exit()'s after printing the statistics): > > if (signal(SIGINT, SIG_IGN) != SIG_IGN) > { > (void) signal(SIGINT, term); > } > > Do folks see any issue with using similar code to add a SIGUSR1 signal > handler?: > > if (signal(SIGUSR1, SIG_IGN) != SIG_IGN) > { > (void) signal(SIGUSR1, stats); > } > > This would minmize the amount of code that would need to be added to > get stats functionality, and would address the license issues. If this > solution isn't acceptable, could I get a sponsor assigned to help me > work through a community approved solution? > > Thanks, > - Ryan
Note that SA_RESTART must be set; otherwise dd from a pipe or other slow device will return an error condition. I also like Casper's suggestion to use sprintf and write to stderr, since sprintf is now async-signal-safe. I can help you get this into shape. - Bart -- Bart Smaalders Solaris Kernel Performance barts at cyber.eng.sun.com http://blogs.sun.com/barts