On 6/3/20 4:22 PM, David CARLIER wrote: > Good point even tough the libproc api is here in this form since quite a time.
Top-posting is difficult to read on technical lists; it's better to reply inline. Also, please don't remove the post content you are replying to... Because then your answer doesn't make much sense out of context. > > From d23bf60961ee036f8298794f879d1b8b9bd717dc Mon Sep 17 00:00:00 2001 > From: David Carlier <devne...@gmail.com> > Date: Tue, 26 May 2020 21:35:27 +0100 > Subject: [PATCH] util/oslib: current process full path resolution on MacOS > > Using existing libproc to fill the path. > > Signed-off-by: David Carlier <devne...@gmail.com> > --- > util/oslib-posix.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/util/oslib-posix.c b/util/oslib-posix.c > index 062236a1ab..9dd1e1a18b 100644 > --- a/util/oslib-posix.c > +++ b/util/oslib-posix.c > @@ -55,6 +55,10 @@ > #include <sys/sysctl.h> > #endif > > +#ifdef __APPLE__ > +#include <libproc.h> > +#endif > + > #include "qemu/mmap-alloc.h" > > #ifdef CONFIG_DEBUG_STACK_USAGE > @@ -366,6 +370,15 @@ void qemu_init_exec_dir(const char *argv0) > p = buf; > } > } > +#elif defined(__APPLE__) > + { > + int len; > + len = proc_pidpath(getpid(), buf, sizeof(buf) - 1); > + if (len <= 0) { > + return; > + } > + p = buf; > + } > #endif > /* If we don't have any way of figuring out the actual executable > location then try argv[0]. */ >