From owner-freebsd-questions Tue Sep 21 16:10:39 1999 Delivered-To: freebsd-questions@freebsd.org Received: from scientia.demon.co.uk (scientia.demon.co.uk [212.228.14.13]) by hub.freebsd.org (Postfix) with ESMTP id 2580F14E1B for ; Tue, 21 Sep 1999 16:10:28 -0700 (PDT) (envelope-from ben@scientia.demon.co.uk) Received: from lithium.scientia.demon.co.uk ([192.168.0.3] ident=exim) by scientia.demon.co.uk with esmtp (Exim 3.032 #1) id 11TXGA-00050k-00; Tue, 21 Sep 1999 22:15:34 +0100 Received: (from ben) by lithium.scientia.demon.co.uk (Exim 3.032 #1) id 11TXG8-000537-00; Tue, 21 Sep 1999 22:15:32 +0100 Date: Tue, 21 Sep 1999 22:15:32 +0100 From: Ben Smithurst To: Alfred Perlstein Cc: "Oleg V. Volkov" , freebsd-questions@FreeBSD.ORG Subject: Re: How to find absolute name of running binary? Message-ID: <19990921221532.A19388@lithium.scientia.demon.co.uk> References: <19990921020955.C16138@fly.lglobus.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.6i In-Reply-To: Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Alfred Perlstein wrote: > On Tue, 21 Sep 1999, Oleg V. Volkov wrote: > >> Well subject says it all. How could i find absolute name of my running >> binary from inside it? References to man or C examples welcome. > > I think some permutation of getcwd(3) and argv[0] should help, perhaps > with lstat (to check if you were run via a symlink) That won't do much if people give the program crap in argv[0], e.g. execlp("foo", "ha ha, fooled you!", "-x", "-y", "z", NULL), will it? There's some about this in some FAQ somewhere (comp.unix.programmer FAQ maybe, I'm not sure), and it basically boils down to "don't do it". I'd like to know what Oleg is doing and why he needs this information. -- Ben Smithurst | PGP: 0x99392F7D ben@scientia.demon.co.uk | key available from keyservers and | ben+pgp@scientia.demon.co.uk To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message