From owner-freebsd-hackers Mon Mar 11 04:49:07 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id EAA06090 for hackers-outgoing; Mon, 11 Mar 1996 04:49:07 -0800 (PST) Received: from nixpbe.pdb.sni.de (mail.sni.de [192.109.2.33]) by freefall.freebsd.org (8.7.3/8.7.3) with ESMTP id EAA06085 for ; Mon, 11 Mar 1996 04:49:01 -0800 (PST) Received: (from nerv@localhost) by nixpbe.pdb.sni.de (8.6.12/8.6.12) id NAA19735 for hackers@freebsd.org; Mon, 11 Mar 1996 13:48:35 +0100 Message-Id: <199603111248.NAA19735@nixpbe.pdb.sni.de> Subject: Re: Weird problem. To: terry@lambert.org (Terry Lambert) Date: Mon, 11 Mar 96 13:45:03 MET From: Greg Lehey Cc: hackers@freebsd.org (Hackers; FreeBSD) In-Reply-To: <199603092059.NAA21396@phaeton.artisoft.com>; from "Terry Lambert" at Mar 9, 96 1:59 pm X-Mailer: xmail 2.4 (based on ELM 2.2 PL16) Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > >> > 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. I suppose you could look at argv [0], but there's no guarantee that the process hasn't changed it. > 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. Greg