Skip to content

dd: report transfer statistics on SIGINFO - #15477

Open
limadog9 wants to merge 1 commit into
uutils:mainfrom
limadog9:fix/dd-siginfo-10776
Open

limadog9 wants to merge 1 commit into
uutils:mainfrom
limadog9:fix/dd-siginfo-10776

Conversation

@limadog9

Copy link
Copy Markdown
Contributor

Handle SIGINFO on macOS and BSD, retaining SIGUSR1 on other Unix systems. Share progress update handling and honor status=none and status=noxfer for signal reports. Add a regression test that requests statistics while copying, then checks that copying and the final report still complete.

Validation: 152 integration tests and 94 unit tests pass on Linux; macOS and FreeBSD test compilation, formatting, and Clippy pass.

Closes #10776

Comment thread src/uu/dd/src/progress.rs Outdated
#[cfg(unix)]
pub(crate) fn install_progress_signal_handler() -> std::io::Result<()> {
// BSD systems (including macOS) use SIGINFO; other Unix systems use SIGUSR1.
let signal = uucore::signals::signal_by_name_or_value("INFO")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why look it up by name at runtime? libc::SIGINFO behind a #[cfg(any(target_vendor = "apple", bsd...))] would be simpler, no?

Comment thread src/uu/dd/src/progress.rs
ProgUpdateType::Signal => {
update.print_transfer_stats(progress_printed);
// Reset the progress printed, since print_transfer_stats always prints a newline.
update.print_final_stats(print_level, progress_printed);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this changes the SIGUSR1 output on linux for status=none/noxfer too, please mention it in the commit message

Comment thread tests/by-util/test_dd.rs Outdated
let signal = Signal::SIGUSR1;
#[cfg(not(target_os = "linux"))]
let signal = Signal::SIGINFO;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please make this test shorter? 70 lines with two polling loops is hard to follow
maybe one small test per status

@limadog9
limadog9 force-pushed the fix/dd-siginfo-10776 branch from c818481 to f3e21f4 Compare October 18, 2026 22:39
Comment thread src/uu/dd/src/progress.rs
ProgUpdateType::Signal => {
update.print_transfer_stats(progress_printed);
// Reset the progress printed, since print_transfer_stats always prints a newline.
update.print_final_stats(print_level, progress_printed);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this changes SIGUSR1 output on linux, could you please run the GNU test?
git clone https://github.com/coreutils/coreutils.git ../gnu
bash util/build-gnu.sh && bash util/run-gnu-test.sh tests/dd/stats.sh

Comment thread src/uu/dd/src/progress.rs Outdated
target_os = "dragonfly"
))]
let signal = libc::SIGINFO;
#[cfg(not(any(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same os list twice, could be a single cfg_if! or a const, no?

Comment thread tests/by-util/test_dd.rs Outdated
target_vendor = "apple",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dragonfly is handled in progress.rs but missing here, on purpose?

@limadog9
limadog9 force-pushed the fix/dd-siginfo-10776 branch 2 times, most recently from d4d8be1 to ede88e9 Compare November 29, 2026 21:48
Handle SIGINFO on Apple and BSD targets and use SIGUSR1 on other
Unix targets. On Linux, SIGUSR1 now honors status=none by suppressing
the report and status=noxfer by printing only record counts.

Exercise all three output modes while copying and check that copying
continues after the signal. Enable the test on DragonFly BSD too.
Existing platform gates in uucore block the DragonFly cross-check.

GNU coreutils 9.12 tests/dd/stats.sh passes on Linux with the updated
dd, as do 154 integration tests and 94 unit tests for dd.

Closes uutils#10776
@sylvestre
sylvestre force-pushed the fix/dd-siginfo-10776 branch from ede88e9 to ad49eb3 Compare November 29, 2026 21:54

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dd is missing SIGINFO handling

2 participants