Skip to content

uptime: uucore/get_uptime should return a Duration #7851

Open
@drinkcat

Description

@drinkcat

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 #7289.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions