summaryrefslogtreecommitdiff
path: root/src/coreclr
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2016-04-18 21:41:33 -0700
committerJan Kotas <jkotas@microsoft.com>2016-04-18 21:41:33 -0700
commitf6a0444dc41a6346d47a126f57bdb76bda85de05 (patch)
tree4f53043da80e943ca5f319300a47b13a06fa0a1f /src/coreclr
parentd28a79fcdbaaeff1da234442cf4e33666c1273f3 (diff)
parent5d34a87755448f602a30c4be632674df1b0e20cc (diff)
downloadcoreclr-f6a0444dc41a6346d47a126f57bdb76bda85de05.tar.gz
coreclr-f6a0444dc41a6346d47a126f57bdb76bda85de05.tar.bz2
coreclr-f6a0444dc41a6346d47a126f57bdb76bda85de05.zip
Merge pull request #4283 from krytarowski/netbsd-support-61
Implement GetEntrypointExecutableAbsolutePath() on NetBSD
Diffstat (limited to 'src/coreclr')
-rw-r--r--src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp b/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp
index 91da5e055b..b9e62fffeb 100644
--- a/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp
+++ b/src/coreclr/hosts/unixcoreruncommon/coreruncommon.cpp
@@ -16,6 +16,7 @@
#include <string>
#include <string.h>
#include <sys/stat.h>
+#include <sys/sysctl.h>
#include "coreruncommon.h"
#include "coreclrhost.h"
#include <unistd.h>
@@ -45,7 +46,7 @@ bool GetEntrypointExecutableAbsolutePath(std::string& entrypointExecutable)
// Get path to the executable for the current process using
// platform specific means.
-#if defined(__linux__)
+#if defined(__linux__) || (defined(__NetBSD__) && !defined(KERN_PROC_PATHNAME))
// On Linux, fetch the entry point EXE absolute path, inclusive of filename.
char exe[PATH_MAX];
ssize_t res = readlink(symlinkEntrypointExecutable, exe, PATH_MAX - 1);
@@ -75,6 +76,23 @@ bool GetEntrypointExecutableAbsolutePath(std::string& entrypointExecutable)
result = true;
}
}
+#elif defined(__NetBSD__) && defined(KERN_PROC_PATHNAME)
+ static const int name[] = {
+ CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME,
+ };
+ char path[MAXPATHLEN];
+ size_t len;
+
+ len = sizeof(path);
+ if (sysctl(name, __arraycount(name), path, &len, NULL, 0) != -1)
+ {
+ entrypointExecutable.assign(path);
+ result = true;
+ }
+ else
+ {
+ result = false;
+ }
#else
// On non-Mac OS, return the symlink that will be resolved by GetAbsolutePath
// to fetch the entrypoint EXE absolute path, inclusive of filename.
@@ -151,7 +169,7 @@ void AddFilesFromDirectoryToTpaList(const char* directory, std::string& tpaList)
".ni.exe",
".exe",
};
-
+
DIR* dir = opendir(directory);
if (dir == nullptr)
{