From owner-freebsd-ports-bugs@FreeBSD.ORG Wed Mar 30 17:30:12 2011 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 59B9D1065673 for ; Wed, 30 Mar 2011 17:30:12 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 0F30F8FC0C for ; Wed, 30 Mar 2011 17:30:12 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p2UHUBtn064419 for ; Wed, 30 Mar 2011 17:30:11 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p2UHUBrI064415; Wed, 30 Mar 2011 17:30:11 GMT (envelope-from gnats) Resent-Date: Wed, 30 Mar 2011 17:30:11 GMT Resent-Message-Id: <201103301730.p2UHUBrI064415@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Jesse Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 78814106566B for ; Wed, 30 Mar 2011 17:22:17 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 662A38FC14 for ; Wed, 30 Mar 2011 17:22:17 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p2UHMH6J012309 for ; Wed, 30 Mar 2011 17:22:17 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id p2UHMHdS012303; Wed, 30 Mar 2011 17:22:17 GMT (envelope-from nobody) Message-Id: <201103301722.p2UHMHdS012303@red.freebsd.org> Date: Wed, 30 Mar 2011 17:22:17 GMT From: Jesse To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/156064: new port: sysutils/cpulimit -- a program to throttle process CPU usage X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2011 17:30:12 -0000 >Number: 156064 >Category: ports >Synopsis: new port: sysutils/cpulimit -- a program to throttle process CPU usage >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed Mar 30 17:30:11 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Jesse >Release: 8.2 >Organization: RM >Environment: FreeBSD 8.2 32-bit >Description: Please find attached my port of CPUlimit from http://cpulimit.sf.net. This program throttles a process's CPU usage to allow other processes to run smoothly or to avoid over-heating. >How-To-Repeat: >Fix: Patch attached with submission follows: # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # cpulimit # cpulimit/Makefile # cpulimit/pkg-descr # cpulimit/distinfo # cpulimit/files # cpulimit/files/patch-makefile # cpulimit/files/patch-cpulimit.c # echo c - cpulimit mkdir -p cpulimit > /dev/null 2>&1 echo x - cpulimit/Makefile sed 's/^X//' >cpulimit/Makefile << 'd4cb032bbe6802f3bc73aa51eb695ab4' X# New ports collection makefile for: cpulimit X# Date created: April 1, 2011 X# Whom: Jesse X# X# $FreeBSD: ports/ftp/bftpd/Makefile,v 1.36 2011/02/10 11:51:01 sylvio Exp $ X# X XPORTNAME= cpulimit XPORTVERSION= 1.1 XCATEGORIES= sysutils XMASTER_SITES= SF/${PORTNAME}/${PORTNAME}/${PORTNAME}/ X XMAINTAINER= jessefrgsmith@yahoo.ca XCOMMENT= A program to limit the CPU usage of a process. X XPLIST_FILES= bin/${PORTNAME} X X Xdo-install: X ${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME} ${PREFIX}/bin/ X.if !defined(NOPORTDOCS) X.endif X X.include d4cb032bbe6802f3bc73aa51eb695ab4 echo x - cpulimit/pkg-descr sed 's/^X//' >cpulimit/pkg-descr << '352c81b5f2774ebdda2676e8d6866d5c' XThe cpulimit program throttles back a process's CPU usage. This allows the Xuser to slow down jobs that would otherwise choke the processor. It is also helpful on laptops where we want to avoid genrating a lot of heat. X XWWW: http://cpulimit.sourceforge.net/ 352c81b5f2774ebdda2676e8d6866d5c echo x - cpulimit/distinfo sed 's/^X//' >cpulimit/distinfo << 'c4f5f1e36ace754d032d49df67aa1f0a' XSHA256 (cpulimit-1.1.tar.gz) = ee734e82692dc496a083c003340b326bd779567f5de99fcae99e451606c85c00 XSIZE (cpulimit-1.1.tar.gz) = 5130 c4f5f1e36ace754d032d49df67aa1f0a echo c - cpulimit/files mkdir -p cpulimit/files > /dev/null 2>&1 echo x - cpulimit/files/patch-makefile sed 's/^X//' >cpulimit/files/patch-makefile << '9bcfc841f4fe28e1b7760995d0d88429' X--- Makefile.old 2005-06-24 07:53:43.000000000 -0300 X+++ Makefile 2010-08-21 15:10:45.000000000 -0300 X@@ -1,7 +1,15 @@ X+PREFIX=/usr/local X+ X all:: cpulimit X X cpulimit: cpulimit.c X- gcc -o cpulimit cpulimit.c -lrt -Wall -O2 X+ gcc -o cpulimit cpulimit.c -lrt -Wall -O2 -lkvm X+ X+install: cpulimit X+ cp cpulimit ${PREFIX}/bin X+ X+deinstall: X+ rm -f ${PREFIX}/bin/cpulimit X X clean: X rm -f *~ cpulimit 9bcfc841f4fe28e1b7760995d0d88429 echo x - cpulimit/files/patch-cpulimit.c sed 's/^X//' >cpulimit/files/patch-cpulimit.c << '8968e897a9353cfafcbb2d493c1807bf' X--- cpulimit.c.orig 2010-08-20 19:35:15.000000000 -0300 X+++ cpulimit.c 2010-08-21 14:17:52.000000000 -0300 X@@ -43,6 +43,15 @@ X #include X #include X X+#include X+#include X+#include X+#include X+#include X+#include X+#include X+ X+ X //kernel time resolution (inverse of one jiffy interval) in Hertz X //i don't know how to detect it, then define to the default (not very clean!) X #define HZ 100 X@@ -235,6 +244,31 @@ X } X X //get jiffies count from /proc filesystem X+int getjiffies(int pid) X+{ X+ kvm_t *my_kernel = NULL; X+ struct kinfo_proc *process_data = NULL; X+ int processes; X+ int my_jiffies = -1; X+ X+ my_kernel = kvm_open(0, 0, 0, O_RDONLY, "kvm_open"); X+ if (! my_kernel) X+ { X+ printf("Error opening kernel vm. You should be running as root.\n"); X+ return -1; X+ } X+ X+ process_data = kvm_getprocs(my_kernel, KERN_PROC_PID, pid, &processes); X+ if ( (process_data) && (processes >= 1) ) X+ my_jiffies = process_data->ki_runtime; X+ X+ kvm_close(my_kernel); X+ if (my_jiffies >= 0) X+ my_jiffies /= 1000; X+ return my_jiffies; X+} X+ X+/* X int getjiffies(int pid) { X static char stat[20]; X static char buffer[1024]; X@@ -255,6 +289,8 @@ X int ktime=atoi(p+1); X return utime+ktime; X } X+*/ X+ X X //process instant photo X struct process_screenshot { 8968e897a9353cfafcbb2d493c1807bf exit >Release-Note: >Audit-Trail: >Unformatted: