GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — cmp: don't reopen /dev/null on Linux by oech3 · Pull Request #267 · uutils/diffutils

Conversation

@oech3

@oech3 oech3 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Don't reopen 2nd /dev/null at fn is_stdout_dev_null on Linux.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

GNU diffutils testsuite comparison:

Test results comparison:
  Current:   TOTAL: 33 / PASSED: 0 / FAILED: 33 / SKIPPED: 0
  Reference: TOTAL: 33 / PASSED: 8 / FAILED: 21 / SKIPPED: 4

Changes from main branch:
  TOTAL: +0
  PASSED: -8
  FAILED: +12

New test failures (12):
  - basic
  - bignum
  - brief-vs-stat-zero-kernel-lies
  - bug-64316
  - cmp
  - diff3
  - help-version
  - large-subopt
  - strcoll-0-names
  - strip-trailing-cr
  - timezone
  - y2038-vs-32bit
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

sylvestre
sylvestre reviewed Oct 18, 2026
View reviewed changes
Comment thread Cargo.toml Outdated
diff = "0.1.13"
itoa = "1.0.11"
regex = "1.10.4"
rustix = { version = "1.1.4", features = ["fs"] }

@sylvestre sylvestre Oct 18, 2026

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

do we really need a new dependency to save one stat() call?
please justify it, or use std (as_fd().try_clone_to_owned() + MetadataExt::rdev())

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@oech3 oech3 Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

try_clone needs additional fcntl call.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
sylvestre
sylvestre reviewed Oct 18, 2026
View reviewed changes
Comment thread Cargo.toml Resolved

Uh oh!

There was an error while loading. Please reload this page.

sylvestre
sylvestre reviewed Oct 18, 2026
View reviewed changes
Comment thread src/cmp.rs Resolved

Uh oh!

There was an error while loading. Please reload this page.

sylvestre
sylvestre reviewed Oct 18, 2026
View reviewed changes
Comment thread src/cmp.rs Resolved

Uh oh!

There was an error while loading. Please reload this page.

@oech3
cmp: don't reopen /dev/null on Linux
3ce9076
@oech3
oech3 force-pushed the linux-dev-null branch from 6e6618c to 3ce9076 Compare October 18, 2026 09:09
sylvestre
sylvestre reviewed Oct 18, 2026
View reviewed changes
Comment thread src/cmp.rs

#[cfg(any(target_os = "linux", target_os = "android"))]
fn is_stdout_dev_null() -> bool {
// as_fd().try_clone_to_owned() needs additional overhead of fcntl

@sylvestre sylvestre Oct 18, 2026

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

the unix version below doesn't need fcntl either (from_raw_fd + forget)
could you please do the same with MetadataExt::rdev() + FileTypeExt::is_char_device() and drop rustix?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@oech3 oech3 Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Is needs unsafe. Is it OK? clap-rs already pulls rustix.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@oech3 oech3 Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think std does not have a feature to check major/minor.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sylvestre

sylvestre commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

The only thing left is whether rustix is needed at all. std can do the same without fcntl, the way the existing unix path already does.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@oech3

oech3 commented Oct 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Other unix has 2nd open call at Ok(dev_null) = fs::metadata("/dev/null"). But Linux does not. I'll reconsider how to do same things with std.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@oech3

oech3 commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

It seems possible, but some magic numbers and bit shift is needed to avoid libc-like crates.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

@sylvestre sylvestre sylvestre left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@oech3 @sylvestre
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.