-
-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix macos process kinfo #258
Fix macos process kinfo #258
Conversation
It looks like the CI failure is from an unrelated |
Thanks for PR, @LovecraftianHorror! I fixed these lints, can you merge 4269b2a from |
9dec4c9
to
b85743c
Compare
Pushed and rebased and it looks like some issues did get picked up that I missed since it's gated for just MacOS. I'll get them sorted out and push the updates! |
Hmmm, how would you prefer me to read Edit: Moving it into |
Yeah, I definitely want to get rid of the |
Thanks for the fast responses. It looks like we're finally all green other than code coverage. Sorry for the bout of CI driven development. I should have paid more attention to the subtle differences between this crate and the other one I made changes on. I'll have to find the time to get |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the bout of CI driven development.
Don't worry about it, that's why CI exists at all :) master
branch is also works as intended now, which is great.
Looks great, thank you once again for pointing the problem! There are two minor things to handle left and I'll merge this PR then
That should cover the requested change. Thanks for being so helpful in following up with this, it was a joy making this PR! |
copy-pasting from rust-psutil/rust-psutil#80 with some small tweaks
In cjbassi/ytop#75 some users, specifically on MacOS, were running into issues where
OsError { source: Os { code: 12, kind: Other, message: "Cannot allocate memory" } }
was being returned when trying to update the process list.I eventually tracked this down to
processes()
that had a couple of issues leading to this problem:reserve
will reserve an additional number of elements represented by the value passed in whereas here it was being given the expected size of all elements in bytes. This was resulting in much more space being reserved than was required.ENOMEM
. Based on this document:However
So I can understand the confusion from the wording, but when it mentions returning
ENOMEM
this is in the form oferrno
, not as the return value from the function call. This manifested where the code would check forENOMEM
fromsysctl
instead oferrno
, which would cause the error to bubble up instead of appropriately retrying. I think the large reserve size made this case easier to hit since it would stall for more time between reading for the required size and attempting to store.I would appreciate a thorough look over the changes since it's pretty close to messing with
unsafe
code and I was able to reproduce the issue on MacOS, but didn't have a chance to verify that the changes work correctly.