Skip to content

[host][darwin]: fix utmpx database parsing#1990

Merged
shirou merged 1 commit intoshirou:masterfrom
uubulb:fix/darwin-utmpx
Jan 14, 2026
Merged

[host][darwin]: fix utmpx database parsing#1990
shirou merged 1 commit intoshirou:masterfrom
uubulb:fix/darwin-utmpx

Conversation

@uubulb
Copy link
Copy Markdown
Contributor

@uubulb uubulb commented Jan 13, 2026

Close #1989

Fixed the parsing logic in UsersWithContext() to align with the current implementation of getutxent(), which uses the compatibility struct utmpx32 to read the utmpx database file /var/run/utmpx.

Since utmpx32 is not available in the system headers, the struct definition must be manually copied from the Darwin Libc source.

@shirou
Copy link
Copy Markdown
Owner

shirou commented Jan 14, 2026

Thank you for your swift PR. This PR changes previously exported types like Utmpx to unexported. This might be a breaking change, but I think it's acceptable since these types were likely not intended to be part of the public API.

I don't have a Mac machine, so I cannot verify this PR works correctly, but it looks good to me.

@nook24, could you verify this PR solves your issue?

@nook24
Copy link
Copy Markdown

nook24 commented Jan 14, 2026

I successfully tested this on an M4 and Intel Mac.

My results:

macOS 26.2 - arm64

User:  macbert
Terminal:  ttys000
Host:
Started:  1768375108

macOS 15.6.1 - Intel

User:  nook24
Terminal:  ttys005
Host:  
Started:  1758904387

Linux (for comparison)

User:  herbert
Terminal:  pts/1
Host:
Started:  1768374935

This was my testing code: https://github.com/nook24/gopsutil-user-test

Thanks for this quick fix! Awesome

Copy link
Copy Markdown
Owner

@shirou shirou left a comment

Choose a reason for hiding this comment

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

Thank you for confirming this, @nook24, and many thanks to @uubulb for the help!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UserStat.Started has a astronomically high value on macOS arm64

3 participants