Ali Bahrami wrote: > Peter Lawrence wrote: >> All, >> has the data file equivalent to dlopen("$ORIGIN/../lib/foo.so) >> been invented already, >> or is there an SOP that I'm not familiar with for accomplishing this ? >> >> what I need is for example "$ORIGIN/../etc/foo.conf" >> >> thanks, >> Pete Lawrence. > > > I'm not sure if there's a better way, but one way would be to feed > the handle you got from dlopen() to dlinfo() and get the > directory (RTLD_DI_ORIGIN). Then, you can add the "../etc/foo.conf" > to it to get the path you need.
And you don't need a handle if you're looking for you're own origin: char buffer[PATH_MAX]; if (dlinfo(RTLD_SELF, RTLD_DI_ORIGIN, (void *)&buffer) != -1) (void) printf("my origin:\t\t%s\n", buffer); -- Rod