From owner-freebsd-hackers@FreeBSD.ORG Fri Jul 20 03:23:47 2007 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 26F9816A418 for ; Fri, 20 Jul 2007 03:23:47 +0000 (UTC) (envelope-from ioplex@gmail.com) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.234]) by mx1.freebsd.org (Postfix) with ESMTP id D794413C461 for ; Fri, 20 Jul 2007 03:23:46 +0000 (UTC) (envelope-from ioplex@gmail.com) Received: by wx-out-0506.google.com with SMTP id i29so618447wxd for ; Thu, 19 Jul 2007 20:23:46 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=GhDWsQ7prcPRQDlKQrIdAjVU/1f78jZMPJhUCfyBBiVrUn2uT7+7mm+RzuegQJD5GShjBiAL2hmYkMAGHDavvjnOKHvdL+VRwfji6Rj4wTwAoBJuzH8PRZe8v9xRT578HHnGTwwLqXqQP6w2T7ERcD/vQz0A1P5DkEv9GXbCLzM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=UPLCuZYYow1v0fvO8GXbsXJOae73YImb/JRNOVfirlngt3Eg4dR/EvY63OxnZYkkffb2LmsGCxQSCXwHlKwh8iqmS0jW2L11Q43d2Gyd8jyNLbcSbh9t+rkXQnLVDXvXvK5n0ia5pkx7+4KN/IY2RIzAmVPjK+m+QJ0qpgleu4U= Received: by 10.70.9.8 with SMTP id 8mr79325wxi.1184901825930; Thu, 19 Jul 2007 20:23:45 -0700 (PDT) Received: by 10.70.38.11 with HTTP; Thu, 19 Jul 2007 20:23:45 -0700 (PDT) Message-ID: <78c6bd860707192023u645a3c39ua713cc4384c3b876@mail.gmail.com> Date: Thu, 19 Jul 2007 23:23:45 -0400 From: "Michael B Allen" To: freebsd-hackers In-Reply-To: <78c6bd860707191900g375f98ado8315603feac50247@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <78c6bd860707191725r14b8bfe3sf15c1f0e30cf82ca@mail.gmail.com> <78c6bd860707191900g375f98ado8315603feac50247@mail.gmail.com> Subject: Re: Path to executable of current process? 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: Fri, 20 Jul 2007 03:23:47 -0000 > Is there any way to get argv[0] for [a particular] process without being root? After more digging I see sysctl seems to be the way to do this but can I get the full path to the executable form kinfo_proc? How does ps do this? static const char * getcmdline(pid_t pid) { static struct kinfo_proc ki_proc; int mib[4], len; mib[0] = CTL_KERN; mib[1] = KERN_PROC; mib[2] = KERN_PROC_PID; mib[3] = pid; len = sizeof(struct kinfo_proc); if (sysctl(mib, 4, &ki_proc, &len, NULL, 0) == -1) return NULL; return ki_proc.ki_??? } Mike