Le 22/01/2016 11:47, Peter Maydell a écrit : > On 22 January 2016 at 10:33, Laurent Vivier <laur...@vivier.eu> wrote: >> Le 22/01/2016 11:01, Petros Angelatos a écrit : >>> This was my initial approach too, but argv[0] can be just the filename >>> like "qemu-arm-static". And while I could add extra logic to look this >>> up in the PATH, someone could run it from a completely different >>> location. Then I looked for a way to get the path of the current >>> executable but every platform has its own way of doing that and I >>> didn't want to add all these cases. >>> >>> https://stackoverflow.com/questions/1023306/finding-current-executables-path-without-proc-self-exe >> >> linux-user works only on linux. >> qemu uses glib-2.0, so you can use g_find_program_in_path(). > > If QEMU was started via execle() to set the environment of the > executed process and that specified environment has a different > PATH, then g_find_program_in_path() will give the wrong answer. > Using AT_EXECFN (perhaps with a fallback to /proc/self/exe) seems > like a better approach to me.
I agree, you can use getauxval(AT_EXECFN). >>> questions. Is it ok that I deleted part of the patch for my reply to >>> code review, or should I have replied inline without deleting >> >> Generally, it's better to not delete parts. So, someone tacking the mail >> thread at a moment can read the whole history in the last mail. > > I tend to happily delete parts and assume that readers have > access to the thread (via the archive or in their mail readers). > Not deleting bits makes it hard to read replies if there's > a conversation about a small part of a large patch. Yes, I do that also... :) Laurent