uutils / uutils/coreutils

`uptime`: uucore/get_uptime should return a `Duration`

Open
#7,851 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

U - uptime
Dominant language
Rust
Stars
24.1k
Forks
2k
Avg merge
1d 5h
Merged PRs (30d)
365

Description

uucore's get_uptime function:

  • Returns a signed integer value (but the uptime can't be a negative value?)
  • Ignores fractional parts of a second even though the Linux kernel provides that in /proc/uptime.

Possibly depending on the fractional timestamp value at boot time, the second point can cause a 1 second offset between GNU coreutils and uutils:

$ uptime --since
2025-04-23 18:26:36
$ cargo run -p uu_uptime -- --since
2025-04-23 18:26:37

I believe we should change the function signature to return a Duration.

Not sure how much we care about semver in uucore, we would need to modify procps/uu_top as well: see https://github.com/uutils/coreutils/pull/7289.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at uucore's get_uptime function and trace its callers in procps and uu_top, as noted in the issue. Check the uu_uptime --since path and the linked behavior against GNU coreutils. Done means the API represents non-negative fractional uptime with Duration and all affected callers compile and preserve the expected timestamp.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.