From owner-freebsd-hackers@FreeBSD.ORG Wed Aug 23 06:44:35 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D0BCB16A4DF for ; Wed, 23 Aug 2006 06:44:35 +0000 (UTC) (envelope-from reko.turja@liukuma.net) Received: from mxfep01.bredband.com (mxfep01.bredband.com [195.54.107.70]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0E3A843D5D for ; Wed, 23 Aug 2006 06:44:34 +0000 (GMT) (envelope-from reko.turja@liukuma.net) Received: from moria.endor.swagman.org ([213.113.4.185] [213.113.4.185]) by mxfep01.bredband.com with ESMTP id <20060823064433.WYUK5813.mxfep01.bredband.com@moria.endor.swagman.org>; Wed, 23 Aug 2006 08:44:33 +0200 Received: from rivendell (rivendell.endor.swagman.org [192.168.10.10]) by moria.endor.swagman.org (Postfix) with SMTP id F02A5C; Wed, 23 Aug 2006 09:44:29 +0300 (EEST) Message-ID: <006f01c6c67f$a0fb7c60$0a0aa8c0@rivendell> From: "Reko Turja" To: References: <16315800.1957801156269547401.JavaMail.root@vms062.mailsrvcs.net> Date: Wed, 23 Aug 2006 09:44:48 +0300 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 Cc: babkin@users.sf.net Subject: Re: Re: Aqcuiring full path to running process from outside the kernel X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Aug 2006 06:44:35 -0000 ----- Original Message ----- From: "Sergey Babkin" To: "Lutz Boehne" ; 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