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

Fix issue 21113: Use sysctl for thisExePath on BSD. #7578

Merged

Conversation

euantorano
Copy link
Contributor

Fixes issue 21113.

I'm quite new to D, and wasn't sure if there's a way to do a condition inside a version, like the following:

version (FreeBSD || NetBSD || DragonFlyBSD) {}

Which would make some of this code slightly cleaner in my opinion.

Sysctl numbers are taken from relevant headers:

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @euantorano! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Auto-close Bugzilla Severity Description
21113 enhancement std.file.thisExePath on NetBSD depends upon the /proc filesystem

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + phobos#7578"

@euantorano euantorano marked this pull request as draft August 4, 2020 20:11
@euantorano euantorano force-pushed the fix/21113-bsd-thisExePath-sysctl branch from 49556f8 to 4ae8c60 Compare August 4, 2020 20:14
@euantorano euantorano force-pushed the fix/21113-bsd-thisExePath-sysctl branch from 4ae8c60 to c518538 Compare August 4, 2020 21:31
@euantorano euantorano marked this pull request as ready for review August 4, 2020 22:07
@thewilsonator
Copy link
Contributor

version (FreeBSD || NetBSD || DragonFlyBSD) {}

No, the way you have done it is the intended way. Forcing giving a name to the version gives documentation and forces you to think about the versioning logic, i.e. not making arbitrary combinations.

@euantorano
Copy link
Contributor Author

version (FreeBSD || NetBSD || DragonFlyBSD) {}

No, the way you have done it is the intended way. Forcing giving a name to the version gives documentation and forces you to think about the versioning logic, i.e. not making arbitrary combinations.

Ah, ok. That makes sense, thanks!

@thewilsonator
Copy link
Contributor

The linked netBSD has #define KERN_PROC_PATHNAME 5 not 9

@euantorano
Copy link
Contributor Author

The linked netBSD has #define KERN_PROC_PATHNAME 5 not 9

        version (NetBSD)
        {
            enum
            {
                KERN_PROC_ARGS = 48,
                KERN_PROC_PATHNAME = 5
            }

            int[4] mib = [CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME];
        }

I think you might be misreading the else which applies to DragonFlyBSD. It's a little confusing because of the nesting of versions.

@thewilsonator
Copy link
Contributor

Oh right, I stand corrected.

@dlang-bot dlang-bot merged commit 8e03a95 into dlang:master Aug 5, 2020
@euantorano euantorano deleted the fix/21113-bsd-thisExePath-sysctl branch August 5, 2020 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants