[vox-tech] Identifying the directory that contains the currently running executable?

Bill Kendrick nbs at sonic.net
Fri Aug 27 11:36:50 PDT 2004


On Fri, Aug 27, 2004 at 11:31:34AM -0700, Ken Herron wrote:
> Bill noted the entry in the /proc filesystem. For systems without /proc 
> there's no simple way to get this.

Yeah, I was wondering... ;)


> The program can examine argv[0], but 
> that may contain only the program name without the directory path, in 
> which case you would generally read the PATH environment variable and 
> look for the program in each directory listed. It's also possible for 
> argv[0] to contain an irrelevant or misleading string, so you shouldn't 
> depend on it if security is an issue.

Such as an alias, for example?  (I suppose I could try testing...)


-bill!
bill at newbreedsoftware.com          "Maybe it's just a parlor trick, like Fry"
http://www.newbreedsoftware.com/             "Like Fry! Like Fry!"
New Breed Software


More information about the vox-tech mailing list