Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Mar 1996 13:24:47 -0700 (MST)
From:      Terry Lambert <terry@lambert.org>
To:        lehey.pad@sni.de (Greg Lehey)
Cc:        terry@lambert.org, hackers@FreeBSD.org
Subject:   Re: Weird problem.
Message-ID:  <199603112024.NAA03782@phaeton.artisoft.com>
In-Reply-To: <199603111248.NAA19735@nixpbe.pdb.sni.de> from "Greg Lehey" at Mar 11, 96 01:45:03 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> >> > Given the pid of a process, is there any way of finding the executable
> >> > file (including complete path) of this process?
> >>
> >> This is one of the Unix FAQs.  No, it's not possible, and nobody could
> >> even guarantee you that the pathname is still available.  If you don't
> >> believe it, consider the following:
> >>
> >> 	./foo & rm -f foo
> >
> > Well, if it hasn't been deleted, it's possible.
> 
> That depends.  Consider this one:
> 
> ln foo bar
> bar &
> 
> If I go back searching the directory structure for the inode number,
> I'm more likely to find foo than bar.  Sure, it's the correct file,
> but it's the wrong name.

8-).  The name isn't an attribute of the file, so I don't think this
is really a problem.

> > But of course, by the time the reverse lookup is complete, it has
> > probably finished running anyway (it's very time consuming, but
> > there is nothing preventing you from writing a program to do it for
> > you).
> 
> Again, that depends.  I have plenty of processes which run for days.
> It shouldn't take *that* long to search the directory tree.

Well, the first search should be of the name cache, *then* the directory
tree.  Presumably, the file had to have been looked up for it to have
been run.

But now we are getting into implementation details for the original
poster, and those are *his* problem, since what he wants to do is
pretty silly.  8-).


					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199603112024.NAA03782>