diff options
author | Chris Robinson <[email protected]> | 2018-11-11 22:19:32 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-11 22:19:32 -0800 |
commit | c23ea494eabd1695b8c43f00bff4b5820c0cd56c (patch) | |
tree | 828b00750ba7608d6558852a540f7452e9c3ed71 /Alc/helpers.cpp | |
parent | 5848dab92d3172ea2f50e0d82f9628fb20c62bd9 (diff) |
Fix getting the process binary for FreeBSD or macOS
Diffstat (limited to 'Alc/helpers.cpp')
-rw-r--r-- | Alc/helpers.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/Alc/helpers.cpp b/Alc/helpers.cpp index 864278bb..0505c729 100644 --- a/Alc/helpers.cpp +++ b/Alc/helpers.cpp @@ -484,21 +484,19 @@ PathNamePair GetProcBinary() { pathname.resize(pathlen + 1); sysctl(mib, 4, pathname.data(), &pathlen, nullptr, 0); - pathname[pathlen] = 0; + pathname.resize(pathlen); } #endif #ifdef HAVE_PROC_PIDPATH if(pathname.empty()) { - const pid_t pid = getpid(); - char procpath[PROC_PIDPATHINFO_MAXSIZE]; - int ret; - - ret = proc_pidpath(pid, procpath, sizeof(procpath)); + char procpath[PROC_PIDPATHINFO_MAXSIZE]{}; + const pid_t pid{getpid()}; + const int ret{proc_pidpath(pid, procpath, sizeof(procpath))}; if(ret < 1) - WARN("proc_pidpath(%d, ...) failed: %s\n", pid, strerror(errno)); + ERR("proc_pidpath(%d, ...) failed: %s\n", pid, strerror(errno)); else - pathname.append(procpath, procpath+strlen(procpath)); + pathname.insert(pathname.end(), procpath, procpath+strlen(procpath)); } #endif if(pathname.empty()) |