Skip to content

who: add pid session leader #9091

@bakanovskii

Description

@bakanovskii

In a libsystemd of version 254 three functions were added (https://manpages.debian.org/experimental/libsystemd-dev/sd_session_get_display.3.en.html#HISTORY):

  • sd_session_get_username()
  • sd_session_get_start_time()
  • sd_session_get_leader()

First 2 can be used to simplify current funcs, but the last one allows us to close get a session leader PID which previously was not available
You can check by running (on a systemd machine)

$ cargo run -q --all-features -- who -Ha
NAME       LINE         TIME       IDLE          PID COMMENT  EXIT
           system boot  2025-10-25 15:10
root     - pts/23       2025-10-27 18:17 22:58           0
root     - pts/11       2025-10-27 17:55 old             0
alexander ? seat0        2025-10-25 15:24 ?               0 (:0)
alexander - tty2         2025-10-25 15:24 old             0 (:0)

$ who -Ha
NAME       LINE         TIME             IDLE          PID COMMENT  EXIT
           system boot  2025-10-25 15:10
root     - pts/23       2025-10-27 18:17 22:57      164244
root     - pts/11       2025-10-27 17:55  old       162288
alexander ? seat0        2025-10-25 15:24   ?          2456 (:0)
alexander - tty2         2025-10-25 15:24  old         2456 (:0)

My only concern is version compatibility
I already implemented the correct behaivor but I need you opinion on this

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions