Xref: utzoo comp.unix.wizards:8624 comp.sources.d:2141 Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!mailrus!tut.cis.ohio-state.edu!mandrill!hal!ncoast!allbery From: allbery@ncoast.UUCP (Brandon S. Allbery) Newsgroups: comp.unix.wizards,comp.sources.d Subject: Re: Finding where an executable was run from -- a proposal. Message-ID: <7791@ncoast.UUCP> Date: 19 May 88 15:20:14 GMT References: <67@uvaarpa.virginia.edu> <6800012@cpe> <4527@hoptoad.uucp> Reply-To: allbery@ncoast.UUCP (Brandon S. Allbery) Followup-To: comp.unix.wizards Organization: Cleveland Public Access UN*X, Cleveland, Oh Lines: 23 As quoted from <4527@hoptoad.uucp> by gnu@hoptoad.uucp (John Gilmore): +--------------- | If exec() would pass this value to the executed program, say as | argv[-1], then a program could reliably know its own name, and apply a | simple transformation to it to find its data files (e.g. for program | "XXXXXX/foo", its data files are found in "XXXXXX/lib/foo/whatever"). | This works for all values of XXXXXX, whether absolute or relative. +--------------- ...until the program does a chdir(), at which point the program must have resolved a relative pathname into an absolute one or it won't be able to use the path any more. Actually, the biggest problem with this is that by the time the kernel has the executable, the pathname has been changed to a (dev, ino) pair. This is less than useful. And as far as know, the kernel doesn't keep the pathname around any longer than necessary (that being namei()). And what happens if I "ln /usr/lib/uucp/uucico ~/etc/poll"? (Not that I advocate doing so, but....) -- Brandon S. Allbery, moderator of comp.sources.misc {well!hoptoad,uunet!marque,cbosgd,sun!mandrill}!ncoast!allbery Delphi: ALLBERY MCI Mail: BALLBERY