Date: Mon, 21 Aug 2006 12:43:44 +0200 From: des@des.no (Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?=) To: Mike Meyer <mwm-keyword-freebsdhackers2.e313df@mired.org> Cc: Reko Turja <reko.turja@liukuma.net>, freebsd-hackers@freebsd.org Subject: Re: Aqcuiring full path to running process from outside the kernel Message-ID: <86sljqnzbz.fsf@xps.des.no> In-Reply-To: <17640.52899.432083.511555@bhuda.mired.org> (Mike Meyer's message of "Sun, 20 Aug 2006 17:05:39 -0400") References: <017601c6c486$6477c370$0a0aa8c0@rivendell> <17640.52899.432083.511555@bhuda.mired.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Mike Meyer <mwm-keyword-freebsdhackers2.e313df@mired.org> writes: > However, you can also make a best effort. Check argv[0] to see if you > have an absolute path. If not, do what the shell would do to find the > executable - look for it on $PATH. Once you've found it, call > realpath(3) to canonicalize the path. You got it the wrong way around. First pass argv[0] to realpath(3), fall back to using $PATH only if realpath(3) fails (which it shouldn't unless you've called chdir(2), chroot(2) or jail(2) earlier in the process, or the executable was moved or removed) DES --=20 Dag-Erling Sm=F8rgrav - des@des.no
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86sljqnzbz.fsf>