Re: [AD] [4.3] get_executable_name |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: Coordination of admins/developers of the game programming library Allegro <alleg-developers@xxxxxxxxxx>
- Subject: Re: [AD] [4.3] get_executable_name
- From: Evert Glebbeek <eglebbk@xxxxxxxxxx>
- Date: Wed, 30 Aug 2006 10:00:16 +0200
> For an absolute path in argv[0], I'll default to that, then look up
procfs and
> then if needed, ps. I don't like calling ps like that though.
The order is more-or-less from best to worst:
if you have getexecname(), use that
if you don't have that but you do have a procfs that provides a symlink,
use that (here there's a distinction between a Linux-style and SystemV
style)
Use ps if there is no other way.
argv[0] is used if and onlyif no other method works and only if there is a
magic main (which there normally isn't). It could arguably go before the
pipe to ps, but it shouldn't go before either getexecname() or the procfs
attempts (or those'd be pointless).
By the way, the function should probably store the result of the first call
and just return that on subsequent calls instead of going through the
hassle of searching again.
Evert