Richard L. Hamilton wrote:
getexecname() will only read /proc/self/auxv _once_ (per exec'd process) if
I read the code correctly (and ld.so.1 will probably have called it once, so
that all user calls are "free" in that regard).

It looks like you can call dlinfo(RTLD_SELF, RTLD_DI_ARGSINFO, &info) with info pointing to a Dl_argsinfo pointer, and after return, info.dla_auxv should be the auxv. This uses code in the dynamic linker, possibly without a system call (since the auxv is indeed on the stack at the start of ld.so at least).

Whether this is any faster than getexecname() given the amount of code this needs to go through in the dynamic linker is another matter though. It seems highly dubious that this is worth the effort even if it's faster, which is unclear. It also seems unhelpfully less portable.

However, getexecname() only returns whatever the pathname was that
was passed to the exec call, which might have been relative or contained
symlinks.  If one wants it cleaned up, one would have to run realpath() on
it, which would end up calling resolvepath(2) (and maybe getcwd(3c)).

+1 on this and the next comment.

So unless you actually _want_ the path as passed to the exec call, I'd say one
system call per exec (since you can cache the result) is cheap, and just
use the readlink() you mentioned.

_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to