Date: Tue, 21 Sep 1999 21:29:36 -0400 From: Laurence Berland <stuyman@confusion.net> To: Ben Smithurst <ben@scientia.demon.co.uk> Cc: Alfred Perlstein <bright@wintelcom.net>, "Oleg V. Volkov" <rover@lglobus.ru>, freebsd-questions@FreeBSD.ORG Subject: Re: How to find absolute name of running binary? Message-ID: <37E83100.F6CBC126@confusion.net> References: <19990921020955.C16138@fly.lglobus.ru> <Pine.BSF.4.05.9909201556110.6368-100000@fw.wintelcom.net> <19990921221532.A19388@lithium.scientia.demon.co.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
So how do programs like gzip/gunzip do it? Where running gunzip is the
same as gzip -d?
Ben Smithurst wrote:
>
> 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
--
Laurence Berland, Stuyvesant HS Debate
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Windows 98: n.
useless extension to a minor patch release for
32-bit extensions and a graphical shell for a
16-bit patch to an 8-bit operating system
originally coded for a 4-bit microprocessor,
written by a 2-bit company that can't stand for
1 bit of competition.
http://stuy.debate.net
icq #7434346 aol imer E1101
The above email Copyright (C) 1999 Laurence Berland
All rights reserved
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?37E83100.F6CBC126>
