aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-03-24 08:25:58 -0700
committerChris Robinson <[email protected]>2018-03-24 08:25:58 -0700
commit3f071a90a4313749b348a7d98284c005e5d87537 (patch)
treeb32ea674925babed8fee91c0ccab5805bacf2482 /Alc
parent413d55aaa547b3f602781ba235a629f3040d3e8d (diff)
Use proc_pidpath to get the process path on macOS when available
Diffstat (limited to 'Alc')
-rw-r--r--Alc/helpers.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/Alc/helpers.c b/Alc/helpers.c
index e5545492..f7adfba0 100644
--- a/Alc/helpers.c
+++ b/Alc/helpers.c
@@ -39,6 +39,9 @@
#ifdef HAVE_DIRENT_H
#include <dirent.h>
#endif
+#ifdef HAVE_PROC_PIDPATH
+#include <libproc.h>
+#endif
#ifdef __FreeBSD__
#include <sys/types.h>
@@ -755,6 +758,27 @@ void GetProcBinary(al_string *path, al_string *fname)
pathname[pathlen] = 0;
}
#endif
+#ifdef HAVE_PROC_PIDPATH
+ if(!pathname)
+ {
+ const pid_t pid = getpid();
+ char procpath[PROC_PIDPATHINFO_MAXSIZE];
+ int ret;
+
+ ret = proc_pidpath(pid, procpath, sizeof(procpath));
+ if(ret < 1)
+ {
+ WARN("proc_pidpath(%d, ...) failed: %s\n", pid, strerror(errno));
+ free(pathname);
+ pathname = NULL;
+ }
+ else
+ {
+ pathlen = strlen(procpath);
+ pathname = strdup(procpath);
+ }
+ }
+#endif
if(!pathname)
{
const char *selfname;