----- Original Message -----
From: "Sergey Babkin" <[EMAIL PROTECTED]>
To: "Lutz Boehne" <[EMAIL PROTECTED]>; <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
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"