From owner-freebsd-questions@FreeBSD.ORG Sun Dec 27 07:49:00 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5E435106566C for ; Sun, 27 Dec 2009 07:49:00 +0000 (UTC) (envelope-from invalid.pointer@gmail.com) Received: from mail-pw0-f44.google.com (mail-pw0-f44.google.com [209.85.160.44]) by mx1.freebsd.org (Postfix) with ESMTP id 23E468FC16 for ; Sun, 27 Dec 2009 07:48:59 +0000 (UTC) Received: by pwi15 with SMTP id 15so6428068pwi.3 for ; Sat, 26 Dec 2009 23:48:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type :content-transfer-encoding; bh=+doXfk9tmAMXN2C1czbWjxCE09mga/NR4E63DQLOF8g=; b=FVdm6v5GqUHDIzMmAapMXdeNJ+0F4MoG+CzphmXSNEzzgNf2l0LamQel1eKbPKP/ri MdZ7/CF1O14mwDaGxFAsHE17D2IIq4QQYntfpcb2WLaTG2rOyzN2RXQjBp44NiM3kMX2 k8gCpsQzGm7gOq7U9yyFUBTkkRNbfFyg2Ka0Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; b=aLkUDGOmIeElpntfnV/AxZ2bt3+0FNj9diPkarLGVB/2Jei2+QkkBmlsTOoay1E8Ee O+x378+QF7zI2wUo61FJ0iHE5U6cIvnim2J7+OFpSn5GPeyJTQTW1JM65TUYncocf18M 5/cIr7OI7DOsBt3wq04joxFxwE+tS2n4sOSxU= Received: by 10.115.113.14 with SMTP id q14mr9619602wam.178.1261900128678; Sat, 26 Dec 2009 23:48:48 -0800 (PST) Received: from ?192.168.1.78? ([122.161.2.247]) by mx.google.com with ESMTPS id 22sm10518698pzk.6.2009.12.26.23.48.46 (version=SSLv3 cipher=RC4-MD5); Sat, 26 Dec 2009 23:48:48 -0800 (PST) Message-ID: <4B37117C.3050502@gmail.com> Date: Sun, 27 Dec 2009 13:19:16 +0530 From: Manish Jain User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) MIME-Version: 1.0 To: freebsd-questions@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Looking for a convenient way in C to retrieve CPU and memory usage of a process X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Dec 2009 07:49:00 -0000 Hello, I am looking for a convenient way using C to retrieve the current CPU and memory utilization of a process of which I have the pid. Can somebody please give me a hint of which system-calls/library-functions to use for this ? I don't want to use the system() function or grep for information via the /proc filesystem. I would be grateful if you could also please mention whether the suggested method[s] is/are FreeBSD-specific or would be portable to other environments like Solaris/Linux ? Thanks for any help. Regards & Happy New Year Manish Jain invalid.pointer@gmail.com