Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Aug 2006 09:44:48 +0300
From:      "Reko Turja" <reko.turja@liukuma.net>
To:        <freebsd-hackers@freebsd.org>
Cc:        babkin@users.sf.net
Subject:   Re: Re: Aqcuiring full path to running process from outside the kernel
Message-ID:  <006f01c6c67f$a0fb7c60$0a0aa8c0@rivendell>
References:  <16315800.1957801156269547401.JavaMail.root@vms062.mailsrvcs.net>

next in thread | previous in thread | raw e-mail | index | archive | help
----- Original Message ----- 
From: "Sergey Babkin" <babkin@verizon.net>
To: "Lutz Boehne" <lboehne@damogran.de>; <freebsd-hackers@freebsd.org>
Sent: Tuesday, August 22, 2006 8:59 PM
Subject: Re: Re: Aqcuiring full path to running process from outside 
thekernel

> So why not just change the compiler to put the contents of
> this file into a DATA section, at some special symbol.
> (I presume that now it puts the messages into some
> kind of a COMMENT section).
> Then instead of reading the file manually you would have
> the contents of the file already pre-mapped into the memory
> for you when the program starts. Saves you lots of trouble.

The "problem" is mainly that for some reason for every platform OW 
supports the file path is fetched somehow. I know the existing code 
which fetches the full path first isn't the most elegant one, but what 
I'm trying to do is get OW to compile first with existing code and 
logic, without breaking too much in the process :)

But as said in earlier post of mine, I managed to achieve what I was 
trying with the following code - using the sysctl seems to achieve 
what was needed reliably enough, at least for now.

int mib[4];
size_t len;
mib[0] = CTL_KERN;
mib[1] = KERN_PROC;
mib[2] = KERN_PROC_PATHNAME;
mib[3] = -1;
len = PATH_MAX;

/* First we try grabbing the path to executable using the sysctl MIB*/
result = sysctl(mib, 4, name, &len, NULL, 0);

I managed to stumble upon this about the same time I got the first 
reply on my question, but for fallback methods I've gotten several 
valuable suggestions and ideas from here, thanks!

-Reko 




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?006f01c6c67f$a0fb7c60$0a0aa8c0>