Skip to content

Commit

Permalink
Using proc_pidpath() API to get the path of the running process, than…
Browse files Browse the repository at this point in the history
…ks to wfeii1980.
  • Loading branch information
zhengshuxin committed Sep 15, 2023
1 parent a2f8327 commit f50da19
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib_acl/src/stdlib/sys/acl_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,16 @@ const char *acl_getcwd()
return (ptr);
}
#elif defined(ACL_MACOSX)
#include <libproc.h>

const char *acl_process_path(void)
{
const char *myname = "acl_process_path";
char *buf_ptr = get_tls_buf();
ssize_t ret;

ret = readlink("/proc/curproc/file", buf_ptr, BUF_SIZE);
// ret = readlink("/proc/curproc/file", buf_ptr, BUF_SIZE);
ret = proc_pidpath(getpid(), buf_ptr, BUF_SIZE);
if (ret < 0) {
acl_msg_error("%s(%d): readlink error(%s)",
myname, __LINE__, acl_last_serror());
Expand Down

0 comments on commit f50da19

Please sign in to comment.