File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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));
You can’t perform that action at this time.
0 commit comments