Skip to content

Commit 525f41c

Browse files
committed
[fs_util] fix self path lookup
1 parent 6d1ff95 commit 525f41c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/base/fs_util.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,13 @@ self_path()
6262
}
6363
return std::nullopt;
6464
#else
65-
char pathbuf[PATH_MAX];
66-
auto rc = readlink("/proc/self/exe", pathbuf, sizeof(pathbuf));
67-
if (rc > 0) {
68-
return std::filesystem::path(pathbuf);
65+
std::error_code ec;
66+
auto target = std::filesystem::read_symlink("/proc/self/exe", ec);
67+
if (ec) {
68+
log_error("failed to read /proc/self/exe: %s", ec.message().c_str());
69+
return std::nullopt;
6970
}
70-
return std::nullopt;
71+
return target;
7172
#endif
7273
}
7374

0 commit comments

Comments
 (0)