LD_LIBRARY_PATH trick PART 2

mpeters on 2008-06-13T18:49:44

In my last post I talked about a trick with setting LD_LIBRARY_PATH in the same script that needs it. Then I ran into some problems with code being run by a perl -e scenario. My new solution (with some help from rjbs) is actually even simpler than what I'm doing now. The downside is it's not really portable. Should work for most *nixes and I only really need it to work on Linux, so I'm good.

The answer lies in asking /proc what command line options I was invoked with:

$ENV{LID_LIBRARY_PATH} = '/some/computed/path';
exec(split("\0", `cat /proc/$$/cmdline`));