*BSD News Article 39055


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!yarrina.connect.com.au!werple.apana.org.au!otis.apana.org.au!serval.net.wsu.edu!netnews.nwnet.net!oracle.pnl.gov!osi-east2.es.net!cronkite.nersc.gov!dancer.ca.sandia.gov!overload.lbl.gov!lll-winken.llnl.gov!uwm.edu!psuvax1!news.pop.psu.edu!hudson.lm.com!news.galt.com!phred.ws.cc.cmu.edu!alex
From: alex@pc.cc.cmu.edu (alex wetmore)
Newsgroups: comp.os.386bsd.development
Subject: Re: How to find the filename of the binary executable...
Date: 7 Dec 1994 04:19:55 GMT
Organization: Phred Networking
Lines: 17
Distribution: world
Message-ID: <3c3d5b$kor@dagny.galt.com>
References: <3c35e2$6sv@shore.shore.net>
NNTP-Posting-Host: phred.ws.cc.cmu.edu
X-Newsreader: TIN [version 1.2 PL2]

Robert Withrow (witr@rwwa.com) wrote:
> Can someone tell me how to find the filename of the *binary*
> file being executed (on, say, FreeBSD 1.1.5.1, or sunos.recent)?

> P.S.: if your answer is argv[0], you don't understand the
> question...

You can't do this.  What if you have the same executable with two names
(through hard links).

Once the executable is running all that can be known about it is the 
inode (someone will correct me if i'm wrong, I don't have Leffler, etc al,
here).  So its impossible to figure out the filename.

The real question is: why do you need to know this?

alex