Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9c5c657

Browse files
authored
Implement GetEntrypointExecutableAbsPath on SunOS (#36430)
* Implement `GetEntrypointExecutableAbsolutePath`. * Fix a warning from newer gawk (v5.0.1 from 2019): > ```sh > awk: /runtime/src/coreclr/src/nativeresources/processrc.awk:54: > warning: regexp escape sequence `\"' is not a known regexp operator > ```
1 parent bdd7235 commit 9c5c657

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/coreclr/src/hosts/unixcoreruncommon/coreruncommon.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,43 @@ bool GetEntrypointExecutableAbsolutePath(std::string& entrypointExecutable)
116116
{
117117
result = false;
118118
}
119+
#elif defined(__sun)
120+
const char *path;
121+
if ((path = getexecname()) == NULL)
122+
{
123+
result = false;
124+
}
125+
else if (*path != '/')
126+
{
127+
char *cwd;
128+
if ((cwd = getcwd(NULL, PATH_MAX)) == NULL)
129+
{
130+
result = false;
131+
}
132+
else
133+
{
134+
char *joined;
135+
if (asprintf(&joined, "%s/%s", cwd, path) < 0)
136+
{
137+
result = false;
138+
}
139+
else
140+
{
141+
entrypointExecutable.assign(joined);
142+
result = true;
143+
free(joined);
144+
}
145+
146+
free(cwd);
147+
}
148+
}
149+
else
150+
{
151+
entrypointExecutable.assign(path);
152+
result = true;
153+
}
154+
155+
free((void*)path);
119156
#else
120157

121158
#if HAVE_GETAUXVAL && defined(AT_EXECFN)

src/coreclr/src/nativeresources/processrc.awk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ BEGIN {
5151
var = var + 0;
5252

5353
# Extract string content starting with either " or L"
54-
idx = match($0, /L?\"/);
54+
idx = match($0, /L?"/);
5555
content = substr($0, idx);
5656

5757
# remove the L prefix from strings

0 commit comments

Comments
 (0)