Skip to content

Commit 1f60b6d

Browse files
committed
update post cmts
Signed-off-by: dsengupta0628 <dsengupta@precisioninno.com>
1 parent c3cab3e commit 1f60b6d

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

bazel/tcl_library_init.cc

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,21 @@ static std::optional<std::string> TclLibraryMountPoint(Tcl_Interp* interp)
4343
std::string error;
4444
// Use /proc/self/exe to resolve the real binary path, as argv[0] may
4545
// point into a sandbox where the .runfiles tree does not exist.
46+
std::string exe_path;
4647
#ifdef __linux__
4748
char buf[PATH_MAX + 1];
4849
ssize_t len = readlink("/proc/self/exe", buf, PATH_MAX);
49-
if (len >= PATH_MAX) {
50-
std::cerr << "[Error] /proc/self/exe path too long (>= PATH_MAX); "
51-
"falling back to Tcl_GetNameOfExecutable()\n";
50+
if (len > 0 && len < PATH_MAX) {
51+
exe_path.assign(buf, len);
52+
} else {
53+
if (len >= PATH_MAX) {
54+
std::cerr << "[Error] /proc/self/exe path too long (>= PATH_MAX); "
55+
"falling back to Tcl_GetNameOfExecutable()\n";
56+
}
57+
exe_path = Tcl_GetNameOfExecutable();
5258
}
53-
std::string exe_path = (len > 0 && len < PATH_MAX)
54-
? std::string(buf, len)
55-
: std::string(Tcl_GetNameOfExecutable());
5659
#else
57-
std::string exe_path(Tcl_GetNameOfExecutable());
60+
exe_path = Tcl_GetNameOfExecutable();
5861
#endif
5962
std::unique_ptr<Runfiles> runfiles(
6063
Runfiles::Create(exe_path, BAZEL_CURRENT_REPOSITORY, &error));

0 commit comments

Comments
 (0)