D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21113 - std.file.thisExePath on NetBSD depends upon the /proc filesystem
Summary: std.file.thisExePath on NetBSD depends upon the /proc filesystem
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All Other
: P1 enhancement
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2020-08-04 19:41 UTC by Euan Torano
Modified: 2020-08-05 08:20 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Euan Torano 2020-08-04 19:41:05 UTC
The function `std.file.thisExPath` depends upon the process filesystem being mounted, which isn't the case by default.

However, NetBSD provides a sysctl to get the path name similar to FreeBSD, as can be sen in this C snippet:

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

Documentation can be found at: https://netbsd.gw.com/cgi-bin/man-cgi?sysctl+7+NetBSD-current

It would be nice to alter the code to make use of this sysctl call instead.
Comment 1 Euan Torano 2020-08-04 20:03:57 UTC
I also noticed that DragonFlyBSD is using procfs too, but has the same sysctl as FreeBSD (though numbered differently of course...): https://man.dragonflybsd.org/?command=sysctl&section=3
Comment 2 Dlang Bot 2020-08-04 20:09:12 UTC
@euantorano created dlang/phobos pull request #7578 "Fix issue 21113: Use sysctl for thisExePath on BSD." fixing this issue:

- Fix issue 21113: Use sysctl for thisExePath on BSD.

https://github.com/dlang/phobos/pull/7578
Comment 3 Dlang Bot 2020-08-05 08:20:18 UTC
dlang/phobos pull request #7578 "Fix issue 21113: Use sysctl for thisExePath on BSD." was merged into master:

- c51853866e38def161c34b0d88e89808d77d3551 by Euan Torano:
  Fix issue 21113: Use sysctl for thisExePath on BSD.

https://github.com/dlang/phobos/pull/7578