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

[FreeBSD] lookup process path via sysctl #5189

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

michael-yuji
Copy link
Contributor

Currently executable importing Foundation may crash when launched with certain shell as a platform specific way to get the path of the process's executable is not defined. This PR implements this missing piece to fetch the process path via sysctl

// in case for whatever reason the path is > PATH_MAX
if (sysctl_ret == -1 && errno == ENOMEM) {
// get size needed
sysctl_ret = sysctl(mib, 4, NULL, &len, NULL, 0);
Copy link
Member

Choose a reason for hiding this comment

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

Any reason to not do this unconditionally to compute the required length?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we should almost never the case when exec path is > PATH_MAX, so we can save an extra syscall in most cases. (In fact, I'm not sure if it's even possible on generic FreeBSD, but there are many FreeBSD variants floating around...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants