use the right sysctl to find the main binary name. We don't really need

this since our dl_iterate_phdr DTRT's for objmain, but...
This commit is contained in:
christos 2016-12-01 18:19:19 +00:00
parent dbf589355f
commit 0833d377e3
1 changed files with 4 additions and 0 deletions

View File

@ -751,7 +751,11 @@ uptr ReadBinaryName(/*out*/char *buf, uptr buf_len) {
return module_name_len;
}
#if SANITIZER_FREEBSD || SANITIZER_NETBSD
# if SANITIZER_FREEBSD
const int Mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
# else
const int Mib[4] = { CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME };
# endif
size_t Size = buf_len;
bool IsErr = (sysctl(Mib, 4, buf, &Size, NULL, 0) != 0);
int readlink_error = IsErr ? errno : 0;