How to get the pathname of the current executable?

Randal Schwartz merlyn at iwarp.intel.com
Thu Feb 8 08:15:38 AEST 1990


In article <1610.25d028a3 at wums.wustl.edu>, bethge at wums writes:
[wants to know how to find the name of the current executable]
| Is there a better (more transparent) way?

No.  This was hashed out about a year ago in either c.u.q or c.u.w.
Basically, it boils down to the fact that you have no idea where you
came from, and the closest you could come is to count on the shells to
*mostly* give you the right answer *most* of the time in argv[0].
However, programs that do execv() are free to provide *whatever* they
want.  So, you're out of luck, and subject to spoofing.

Just another UNIX hacker,
-- 
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\
| on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III      |
| merlyn at iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/



More information about the Comp.unix.questions mailing list