Front page | perl.perl5.porters |
Postings from May 2001
Re: Relocatable perl
Thread Previous
|
Thread Next
From:
Jarkko Hietaniemi
Date:
May 3, 2001 11:15
Subject:
Re: Relocatable perl
Message ID:
20010503131440.L4815@chaos.wustl.edu
> In my own code, I check at runtime for the existence of /proc/self/exe
> and fall back to $ENV{PATH} chasing and other gunk. The whole thing
> looks like:
>
> 1. if /proc/self/exe exists, use it and return;
> 2. if argv[0] starts with /, use it and return;
> 3. if argv[0] contains any /'s then getcwd and glue them together
> 4. else chase getenv(PATH).
The 2.-4. are what the UNIX Programming FAQ recommends.
It also somewhat condescendingly suggests that asking the question
usually indicates bad design: "The most common reason people ask this
question is in order to locate configuration files with their
program. This is considered to be bad form; directories containing
executables should contain nothing except executables, and
administrative requirements often make it desirable for configuration
files to be located on different filesystems to executables."
How thoughtful of them... I would have thought that a program with all
its files being fully relocatable would be a good thing. Of course
it's true that a file may have many names, thanks to link(), but
argv[0] being often just the executable name without the path is
somewhat silly.
--
$jhi++; # http://www.iki.fi/jhi/
# There is this special biologist word we use for 'stable'.
# It is 'dead'. -- Jack Cohen
Thread Previous
|
Thread Next