Skip to content
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

[macOS] dynamic set buffer size for process connections/fds (fixes #1901) #1903

Merged
merged 13 commits into from
Oct 5, 2021

Conversation

giampaolo
Copy link
Owner

Summary

Description

proc_pidinfo(PROC_PIDLISTFDS) (second call), which is used to list process fds, can fail in case the buffer is not big enough. This PR tries to allocate the buffer dynamically, by calling proc_pidinfo() in a loop, and enlarging the buffer size on each loop.
Before this, a mismatched or "not big enough" buf size, was considered an error which was translated to AccessDenied.

Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
@giampaolo giampaolo changed the title [macOS] dynamic list fds size #1901 [macOS] dynamic buf size for process connections/fds (fixes #1901) Jan 7, 2021
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
This was done in order to solve
#1044 and
#1100
...but its logic duplicates the one in wrap_exceptions()
decorator.

Also, this should solve #1901 as it did erroneously translated NSP in
AD.

Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
@giampaolo giampaolo changed the title [macOS] dynamic buf size for process connections/fds (fixes #1901) [macOS] dynamic set buffer size for process connections/fds (fixes #1901) Oct 5, 2021
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
@giampaolo giampaolo merged commit e15922b into master Oct 5, 2021
@giampaolo giampaolo deleted the osx-list-fds-refact branch October 5, 2021 17:20
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.

[MacOS] Race condition in Process.get_connections randomly raises AccessDenied
1 participant