uptime: Support files in uptime - #6400
Merged
sylvestre merged 16 commits intoJun 22, 2024
Merged
Conversation
|
GNU testsuite comparison: |
AnirbanHalder654322
marked this pull request as draft
May 14, 2024 17:25
AnirbanHalder654322
force-pushed
the
support_files_in_uptime
branch
3 times, most recently
from
May 19, 2024 17:29
4fc2074 to
3a5ce83
Compare
|
GNU testsuite comparison: |
AnirbanHalder654322
force-pushed
the
support_files_in_uptime
branch
from
May 19, 2024 18:44
ea305b8 to
3a5ce83
Compare
AnirbanHalder654322
marked this pull request as ready for review
May 19, 2024 18:49
AnirbanHalder654322
marked this pull request as draft
May 22, 2024 13:58
AnirbanHalder654322
force-pushed
the
support_files_in_uptime
branch
2 times, most recently
from
May 25, 2024 09:02
76a5692 to
7dd90ba
Compare
… failing for macos
AnirbanHalder654322
force-pushed
the
support_files_in_uptime
branch
from
May 25, 2024 09:03
7dd90ba to
ce55ec1
Compare
sylvestre
reviewed
May 25, 2024
AnirbanHalder654322
force-pushed
the
support_files_in_uptime
branch
from
May 25, 2024 09:30
ce55ec1 to
de56e06
Compare
AnirbanHalder654322
marked this pull request as ready for review
May 25, 2024 09:41
AnirbanHalder654322
force-pushed
the
support_files_in_uptime
branch
from
May 25, 2024 10:50
b5cab86 to
de6a550
Compare
AnirbanHalder654322
marked this pull request as draft
May 25, 2024 11:54
AnirbanHalder654322
force-pushed
the
support_files_in_uptime
branch
3 times, most recently
from
May 26, 2024 12:46
c6e9990 to
002edae
Compare
Contributor
Author
|
Changes since last push: The test |
|
GNU testsuite comparison: |
Contributor
Author
|
The failing CI tests are unrelated to my PR. |
|
GNU testsuite comparison: |
sylvestre
reviewed
Jun 2, 2024
AnirbanHalder654322
force-pushed
the
support_files_in_uptime
branch
from
June 2, 2024 13:09
266de7b to
4a8c460
Compare
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
Contributor
Author
|
@sylvestre does this require any more changes ? |
|
GNU testsuite comparison: |
sylvestre
reviewed
Jun 19, 2024
sylvestre
reviewed
Jun 19, 2024
AnirbanHalder654322
force-pushed
the
support_files_in_uptime
branch
from
June 21, 2024 17:39
2d8d270 to
2b94a69
Compare
|
GNU testsuite comparison: |
Contributor
Author
|
Changes since last push:
|
Contributor
|
thanks! |
naoNao89
added a commit
to naoNao89/coreutils
that referenced
this pull request
Oct 14, 2025
If utmpx BOOT_TIME is unavailable, derive boot time via sysctl CTL_KERN.KERN_BOOTTIME to reduce intermittent macOS failures (e.g., uutils#3621). Context (blame/history): - 2774274 ("uptime: Support files in uptime (uutils#6400)"): added macOS utmpxname validation and non-fatal 'unknown uptime' fallback with tests (tests/by-util/test_uptime.rs). - 920d29f ("uptime: add support for OpenBSD using utmp"): reorganized uptime.rs and solidified utmp/utmpx-driven paths.
sylvestre
pushed a commit
that referenced
this pull request
Dec 26, 2025
* fix(uucore): use sysctl kern.boottime on macOS as fallback for uptime If utmpx BOOT_TIME is unavailable, derive boot time via sysctl CTL_KERN.KERN_BOOTTIME to reduce intermittent macOS failures (e.g., #3621). Context (blame/history): - 2774274 ("uptime: Support files in uptime (#6400)"): added macOS utmpxname validation and non-fatal 'unknown uptime' fallback with tests (tests/by-util/test_uptime.rs). - 920d29f ("uptime: add support for OpenBSD using utmp"): reorganized uptime.rs and solidified utmp/utmpx-driven paths. * test: add comprehensive macOS tests for sysctl kern.boottime fallback Add unit tests for sysctl boottime availability and get_uptime reliability on macOS, verifying the fallback mechanism works correctly when utmpx BOOT_TIME is unavailable. Add integration tests to ensure uptime command consistently succeeds on macOS with various flags (default, --since) and produces properly formatted output. Enhance documentation of the sysctl fallback code with detailed comments explaining why it exists, the issue it addresses (#3621), and comprehensive SAFETY comments for the unsafe sysctl call. All tests are properly gated with #[cfg(target_os = "macos")] to ensure they only run on macOS and don't interfere with other platforms. * refactor(uucore): replace unsafe sysctl with safe command-line approach for macOS boot time - Remove unsafe libc::sysctl() system call entirely - Replace with safe std::process::Command executing 'sysctl -n kern.boottime' - Parse sysctl output format to extract boot time seconds - Maintains same API and functionality while eliminating unsafe blocks - Addresses reviewer feedback to completely remove unsafe code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #6393
Edit1 : I strace-d the whole thing , we seem to use more than 2x amount of read sys calls (will result in more than 100 extra read calls for very large iterations)compared to GNU uptime, which i believe is due to
iter_all_records_fromfunction in uucore::src::lib::features::utmpx