Re: Re: Aqcuiring full path to running process from outside the kernel
- From: "Reko Turja" <reko.turja@xxxxxxxxxxx>
- Date: Wed, 23 Aug 2006 09:44:48 +0300
----- Original Message ----- From: "Sergey Babkin" <babkin@xxxxxxxxxxx>
To: "Lutz Boehne" <lboehne@xxxxxxxxxxx>; <freebsd-hackers@xxxxxxxxxxx>
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@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"
- Follow-Ups:
- Re: Aqcuiring full path to running process from outside the ?kernel
- From: Oliver Fromme
- Re: Aqcuiring full path to running process from outside the ?kernel
- References:
- Re: Re: Aqcuiring full path to running process from outside the kernel
- From: Sergey Babkin
- Re: Re: Aqcuiring full path to running process from outside the kernel
- Prev by Date: Re: style(9)-like guide for man pages
- Next by Date: Re: exception handling in kernel code
- Previous by thread: Re: Aqcuiring full path to running process from outside the kernel
- Next by thread: Re: Aqcuiring full path to running process from outside the ?kernel
- Index(es):
Relevant Pages
|