aboutsummaryrefslogtreecommitdiff
path: root/sysutils/cpulimit
diff options
context:
space:
mode:
authorDennis Herrmann <dhn@FreeBSD.org>2011-03-31 15:01:45 +0000
committerDennis Herrmann <dhn@FreeBSD.org>2011-03-31 15:01:45 +0000
commitec140ddc1d3432c0f3dc6ff00fb4a6a25ab2b95e (patch)
tree116faa812248214ab0e8a68fedb427dd4161f6ed /sysutils/cpulimit
parent524c4b78fbdfaaffa0ea0615b3b97e6d40234ce0 (diff)
downloadports-ec140ddc1d3432c0f3dc6ff00fb4a6a25ab2b95e.tar.gz
ports-ec140ddc1d3432c0f3dc6ff00fb4a6a25ab2b95e.zip
The cpulimit program throttles back a process's CPU usage. This allows the
user 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. WWW: http://cpulimit.sourceforge.net/ PR: ports/156064 Submitted by: Jesse <jessefrgsmith@yahoo.ca>
Notes
Notes: svn path=/head/; revision=272051
Diffstat (limited to 'sysutils/cpulimit')
-rw-r--r--sysutils/cpulimit/Makefile23
-rw-r--r--sysutils/cpulimit/distinfo2
-rw-r--r--sysutils/cpulimit/files/patch-cpulimit.c59
-rw-r--r--sysutils/cpulimit/files/patch-makefile19
-rw-r--r--sysutils/cpulimit/pkg-descr5
5 files changed, 108 insertions, 0 deletions
diff --git a/sysutils/cpulimit/Makefile b/sysutils/cpulimit/Makefile
new file mode 100644
index 000000000000..0b7339d8eee4
--- /dev/null
+++ b/sysutils/cpulimit/Makefile
@@ -0,0 +1,23 @@
+# New ports collection makefile for: cpulimit
+# Date created: April 1, 2011
+# Whom: Jesse
+#
+# $FreeBSD$
+#
+
+PORTNAME= cpulimit
+PORTVERSION= 1.1
+CATEGORIES= sysutils
+MASTER_SITES= SF/${PORTNAME}/${PORTNAME}/${PORTNAME}/
+
+MAINTAINER= jessefrgsmith@yahoo.ca
+COMMENT= A program to limit the CPU usage of a process
+
+PLIST_FILES= bin/${PORTNAME}
+
+do-install:
+ ${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME} ${PREFIX}/bin/
+.if !defined(NOPORTDOCS)
+.endif
+
+.include <bsd.port.mk>
diff --git a/sysutils/cpulimit/distinfo b/sysutils/cpulimit/distinfo
new file mode 100644
index 000000000000..848e0a69fb05
--- /dev/null
+++ b/sysutils/cpulimit/distinfo
@@ -0,0 +1,2 @@
+SHA256 (cpulimit-1.1.tar.gz) = ee734e82692dc496a083c003340b326bd779567f5de99fcae99e451606c85c00
+SIZE (cpulimit-1.1.tar.gz) = 5130
diff --git a/sysutils/cpulimit/files/patch-cpulimit.c b/sysutils/cpulimit/files/patch-cpulimit.c
new file mode 100644
index 000000000000..c6d1b5c47658
--- /dev/null
+++ b/sysutils/cpulimit/files/patch-cpulimit.c
@@ -0,0 +1,59 @@
+--- cpulimit.c.orig 2010-08-20 19:35:15.000000000 -0300
++++ cpulimit.c 2010-08-21 14:17:52.000000000 -0300
+@@ -43,6 +43,15 @@
+ #include <errno.h>
+ #include <string.h>
+
++#include <limits.h>
++#include <fcntl.h>
++#include <kvm.h>
++#include <paths.h>
++#include <sys/param.h>
++#include <sys/sysctl.h>
++#include <sys/user.h>
++
++
+ //kernel time resolution (inverse of one jiffy interval) in Hertz
+ //i don't know how to detect it, then define to the default (not very clean!)
+ #define HZ 100
+@@ -235,6 +244,31 @@
+ }
+
+ //get jiffies count from /proc filesystem
++int getjiffies(int pid)
++{
++ kvm_t *my_kernel = NULL;
++ struct kinfo_proc *process_data = NULL;
++ int processes;
++ int my_jiffies = -1;
++
++ my_kernel = kvm_open(0, 0, 0, O_RDONLY, "kvm_open");
++ if (! my_kernel)
++ {
++ printf("Error opening kernel vm. You should be running as root.\n");
++ return -1;
++ }
++
++ process_data = kvm_getprocs(my_kernel, KERN_PROC_PID, pid, &processes);
++ if ( (process_data) && (processes >= 1) )
++ my_jiffies = process_data->ki_runtime;
++
++ kvm_close(my_kernel);
++ if (my_jiffies >= 0)
++ my_jiffies /= 1000;
++ return my_jiffies;
++}
++
++/*
+ int getjiffies(int pid) {
+ static char stat[20];
+ static char buffer[1024];
+@@ -255,6 +289,8 @@
+ int ktime=atoi(p+1);
+ return utime+ktime;
+ }
++*/
++
+
+ //process instant photo
+ struct process_screenshot {
diff --git a/sysutils/cpulimit/files/patch-makefile b/sysutils/cpulimit/files/patch-makefile
new file mode 100644
index 000000000000..426bf3a20fd0
--- /dev/null
+++ b/sysutils/cpulimit/files/patch-makefile
@@ -0,0 +1,19 @@
+--- Makefile.old 2005-06-24 07:53:43.000000000 -0300
++++ Makefile 2010-08-21 15:10:45.000000000 -0300
+@@ -1,7 +1,15 @@
++PREFIX=/usr/local
++
+ all:: cpulimit
+
+ cpulimit: cpulimit.c
+- gcc -o cpulimit cpulimit.c -lrt -Wall -O2
++ gcc -o cpulimit cpulimit.c -lrt -Wall -O2 -lkvm
++
++install: cpulimit
++ cp cpulimit ${PREFIX}/bin
++
++deinstall:
++ rm -f ${PREFIX}/bin/cpulimit
+
+ clean:
+ rm -f *~ cpulimit
diff --git a/sysutils/cpulimit/pkg-descr b/sysutils/cpulimit/pkg-descr
new file mode 100644
index 000000000000..6a969159a6d7
--- /dev/null
+++ b/sysutils/cpulimit/pkg-descr
@@ -0,0 +1,5 @@
+The cpulimit program throttles back a process's CPU usage. This allows the
+user 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.
+
+WWW: http://cpulimit.sourceforge.net/