New upstream release.
authorgregor herrmann <gregoa@debian.org>
Sun, 8 May 2011 12:59:47 +0000 (12:59 -0000)
committergregor herrmann <gregoa@debian.org>
Sun, 8 May 2011 12:59:47 +0000 (12:59 -0000)
15 files changed:
debian/README.source [new file with mode: 0644]
debian/changelog [new file with mode: 0644]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/copyright [new file with mode: 0644]
debian/cpulimit.1 [new file with mode: 0644]
debian/cpulimit.install [new file with mode: 0644]
debian/cpulimit.manpages [new file with mode: 0644]
debian/patches/01_priority.patch [new file with mode: 0644]
debian/patches/02_segfault_longoptions.patch [new file with mode: 0644]
debian/patches/03_Makefile.patch [new file with mode: 0644]
debian/patches/04_opendir_leak.patch [new file with mode: 0644]
debian/patches/series [new file with mode: 0644]
debian/rules [new file with mode: 0755]
debian/watch [new file with mode: 0644]

diff --git a/debian/README.source b/debian/README.source
new file mode 100644 (file)
index 0000000..0ea6b75
--- /dev/null
@@ -0,0 +1,4 @@
+This package uses quilt to manage patches.
+
+Please refer to /usr/share/doc/quilt/README.source if you need help with
+using quilt for Debian packages.
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..f3093a8
--- /dev/null
@@ -0,0 +1,122 @@
+cpulimit (1.3-1) UNRELEASED; urgency=low
+
+  * New upstream release.
+
+ -- gregor herrmann <gregoa@debian.org>  Sun, 08 May 2011 14:58:46 +0200
+
+cpulimit (1.1-13) unstable; urgency=low
+
+  * Add patch 04_opendir_leak.patch: cpulimit was leaking opendir() handles.
+    Thanks to Johan Walles for the bug report and the patch (closes: #564517).
+  * debian/copyright: update formatting, fix reference to common-licenses, and
+    add stanza for debian/*.
+
+ -- gregor herrmann <gregoa@debian.org>  Wed, 13 Jan 2010 18:57:37 +0100
+
+cpulimit (1.1-12) unstable; urgency=low
+
+  * Add 03_Makefile.patch: allows to set CFLAGS; use CFLAGS in
+    debian/rules; thanks again to Cesare Tirabassi!
+  * debian/watch: back to the redirector at qa.debian.org.
+  * Capitalize 'CPU' in short and long description, thanks to Filipus Klutiero
+    for the bug report (closes: #542868).
+  * Switch to debhelper 7.
+  * Set Standards-Version to 3.8.3 (no changes).
+  * debian/control: make short description a noun phrase.
+  * Update manpage with a note about cpulimit breaking interactive shells;
+    thanks to Jakub Wilk for the bug report (closes: #558763).
+
+ -- gregor herrmann <gregoa@debian.org>  Mon, 07 Dec 2009 20:46:11 +0100
+
+cpulimit (1.1-11) unstable; urgency=low
+
+  * debian/rules:
+    - general cleanup
+    - create install-stamp target in debian/rules and re-arrange dependencies
+    - remove configure and configure-stamp targets
+  * Drop debian/dirs, install binary with dh_install from debian/rules.
+  * debian/control:
+    - Move upstream URL from the description to the new Homepage field
+    - change XS-Vcs-* fields to Vcs-*
+    - change my email address
+  * Switch patch system from dpatch to quilt.
+  * Add patch 02_segfault_longoptions.patch; fixes segfault with long
+    options (closes: #487233, LP: #241538). Thanks to Daniel van
+    Eeden for reporting the problem and to Cesare Tirabassi for the patch.
+  * Set Standards-Version to 3.8.0; add debian/README.source to document quilt
+    usage.
+  * Change debian/copyright to the new machine-readable format.
+  * Set debhelper compatibility level to 6.
+  * debian/watch: use sourceforge URL directly instead of the redirector at
+    qa.debian.org.
+
+ -- gregor herrmann <gregoa@debian.org>  Fri, 20 Jun 2008 15:41:58 +0200
+
+cpulimit (1.1-10) unstable; urgency=low
+
+  * Add patch to fix 'cpulimit drops priority, then can't get back up. Fix
+    included'. Thanks to Ariel for providing the patch. (Closes: #412421)
+
+ -- gregor herrmann <gregor+debian@comodo.priv.at>  Sat,  3 Mar 2007 21:59:06 +0100
+
+cpulimit (1.1-9) unstable; urgency=low
+
+  * Change watch file, update Homepage: field in debian/control, and mention 
+    new download URL in debian/copyright (also closes: #410505).
+
+ -- gregor herrmann <gregor+debian@comodo.priv.at>  Sun, 11 Feb 2007 14:09:13 +0100
+
+cpulimit (1.1-8) unstable; urgency=low
+
+  * Move the cpulimit binary from /usr/sbin to /usr/bin in accordance with the FHS
+    (closes: #400842).
+
+ -- gregor herrmann <gregor+debian@comodo.priv.at>  Thu, 30 Nov 2006 19:45:36 +0100
+
+cpulimit (1.1-7) unstable; urgency=low
+
+  * Change homepage in debian/control.
+
+ -- gregor herrmann <gregor+debian@comodo.priv.at>  Sat, 19 Aug 2006 03:55:18 +0200
+
+cpulimit (1.1-6) unstable; urgency=low
+
+  * Add Tony Mancill to Uploaders.
+  * Add examples to manpage (closes: #374838).
+
+ -- gregor herrmann <gregor+debian@comodo.priv.at>  Sun,  2 Jul 2006 13:16:54 +0200
+
+cpulimit (1.1-5) unstable; urgency=low
+
+  * Update to Standards-Version: 3.7.2 (no changes required).
+  * Move cpulimit from /usr/bin to /usr/sbin.
+  * Fix clean target in debian/rules.
+  * Move manpage from section 1 to 8.
+  * Initial upload to the Debian archive (closes: #367028).
+
+ -- gregor herrmann <gregor+debian@comodo.priv.at>  Sat, 13 May 2006 00:02:39 +0200
+
+cpulimit (1.1-4) unstable; urgency=low
+
+  * Update to Standards-Version: 3.7.0 (no changes required).
+
+ -- gregor herrmann <gregor+debian@comodo.priv.at>  Mon,  1 May 2006 14:30:09 +0200
+
+cpulimit (1.1-3) unstable; urgency=low
+
+  * Fixed reference to copyright file in debian/copyright.
+
+ -- gregor herrmann <gregor+debian@comodo.priv.at>  Thu, 20 Apr 2006 18:21:27 +0200
+
+cpulimit (1.1-2) unstable; urgency=low
+
+  * Fixed watch file.
+
+ -- gregor herrmann <gregor+debian@comodo.priv.at>  Sun, 16 Apr 2006 14:14:59 +0200
+
+cpulimit (1.1-1) unstable; urgency=low
+
+  * Initial release.
+
+ -- gregor herrmann <gregor+debian@comodo.priv.at>  Mon,  3 Apr 2006 21:51:36 +0200
+
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..1e8b314
--- /dev/null
@@ -0,0 +1 @@
+6
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..0eb3fdd
--- /dev/null
@@ -0,0 +1,21 @@
+Source: cpulimit
+Section: admin
+Priority: optional
+Maintainer: gregor herrmann <gregoa@debian.org>
+Uploaders: tony mancill <tmancill@debian.org>
+Build-Depends: debhelper (>= 7.0.8), quilt (>= 0.46-7)
+Standards-Version: 3.8.3
+Homepage: http://cpulimit.sourceforge.net/
+Vcs-Svn: http://svn.toastfreeware.priv.at/debian/cpulimit/trunk/
+Vcs-Browser: http://svn.toastfreeware.priv.at/wsvn/ToastfreewareDebian/cpulimit/trunk/
+
+Package: cpulimit
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: tool for limiting the CPU usage of a process
+ cpulimit is a simple program that attempts to limit the CPU usage of a
+ process (expressed in percentage, not in CPU time). This is useful to
+ control batch jobs, when you don't want them to eat too much CPU. It does
+ not act on the nice value or other priority stuff, but on the real CPU
+ usage.  Besides it is able to adapt itself to the overall system load,
+ dynamically and quickly.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644 (file)
index 0000000..cd89159
--- /dev/null
@@ -0,0 +1,22 @@
+Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=135
+Maintainer: Angelo Marletta
+Source: https://sourceforge.net/project/showfiles.php?group_id=174425
+Name: cpulimit
+
+Files: *
+Copyright: © 2005 Angelo Marletta <marlonx80@hotmail.com>
+License: LGPL-2+
+
+Files: debian/*
+Copyright: 2006-2010, gregor herrmann <gregoa@debian.org>
+ 2006-2010, tony mancill <tmancill@debian.org>
+License: LGPL-2+
+
+License: LGPL-2+ 
+    This program is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+    .        
+    On Debian GNU/Linux systems, the complete text of the GNU Library/Lesser
+    Public License can be found in `/usr/share/common-licenses/LGPL-2'.
diff --git a/debian/cpulimit.1 b/debian/cpulimit.1
new file mode 100644 (file)
index 0000000..78710bf
--- /dev/null
@@ -0,0 +1,70 @@
+.TH CPULIMIT "1" "December 2009" "cpulimit" "User commands"
+.SH NAME
+cpulimit -- limits the CPU usage of a process
+.SH SYNOPSIS
+.B cpulimit
+\fITARGET \fR[\fIOPTIONS\fR...]
+.SH DESCRIPTION
+.P
+\fITARGET \fRmust be exactly one of these:
+.TP
+\fB\-p\fR, \fB\-\-pid\fR=\fIN\fR
+pid of the process
+.TP
+\fB\-e\fR, \fB\-\-exe\fR=\fIFILE\fR
+name of the executable program file
+.TP
+\fB\-P\fR, \fB\-\-path\fR=\fIPATH\fR
+absolute path name of the executable program file
+.P
+\fIOPTIONS\fR
+.TP
+\fB\-l\fR, \fB\-\-limit\fR=\fIN\fR
+percentage of CPU allowed from 0 to 100 (mandatory)
+.TP
+\fB\-v\fR, \fB\-\-verbose\fR
+show control statistics
+.TP
+\fB\-z\fR, \fB\-\-lazy\fR
+exit if there is no suitable target process, or if it dies
+.TP
+\fB\-h\fR, \fB\-\-help\fR
+display this help and exit
+.SH EXAMPLES
+Assuming you have started \fB`foo \-\-bar`\fR and you find out with \fItop\fR(1) or
+\fIps\fR(1) that this process uses all your CPU time you can either
+.TP
+\[sh] \fBcpulimit \-e foo \-l 50\fR
+limits the CPU usage of the process by acting on the executable program file
+(note: the argument "\-\-bar" is omitted)
+.TP
+\[sh] \fBcpulimit \-p 1234 \-l 50\fR
+limits the CPU usage of the process by acting on its PID, as shown by
+\fIps\fR(1)
+.TP
+\[sh] \fBcpulimit \-P /usr/bin/foo \-l 50\fR
+same as \fI\-e\fR but uses the absolute path name
+.SH NOTES
+.IP \(bu 4
+cpulimit always sends the SIGSTOP and SIGCONT signals to a process, 
+both to verify
+that it can control it and 
+to limit the average amount of CPU it consumes.  This can result in
+misleading (annoying) job control messages that indicate that the job 
+has been stopped (when actually it was, but immediately restarted).  
+This can also cause issues with interactive shells that detect or otherwise
+depend on SIGSTOP/SIGCONT.   For example,
+you may place a job in the foreground, only to see it immediately stopped
+and restarted in the background.  (See also <http://bugs.debian.org/558763>.)
+.IP \(bu 4
+When invoked with the \fI\-e\fR or \fI\-P\fR options, cpulimit looks for 
+any process under /proc with a name that matches the process name argument 
+given.  Furthermore, it uses the first instance of the process found.  
+To control a specific instance of a process, use the \fI\-p\fR option 
+and provide a PID.
+.IP \(bu 4
+The current version of cpulimit assumes the kernel HZ value 100.
+
+.SH AUTHOR
+This manpage was written for the Debian project by gregor herrmann 
+<gregoa@debian.org> but may be used by others.
diff --git a/debian/cpulimit.install b/debian/cpulimit.install
new file mode 100644 (file)
index 0000000..acc4f26
--- /dev/null
@@ -0,0 +1 @@
+cpulimit usr/bin
diff --git a/debian/cpulimit.manpages b/debian/cpulimit.manpages
new file mode 100644 (file)
index 0000000..4f10d92
--- /dev/null
@@ -0,0 +1 @@
+debian/cpulimit.1
diff --git a/debian/patches/01_priority.patch b/debian/patches/01_priority.patch
new file mode 100644 (file)
index 0000000..5effb2b
--- /dev/null
@@ -0,0 +1,108 @@
+Author: Ariel <asdebian@dsgml.com>
+Description: only drop priority if it can be raised too
+             and implement RLIMIT_NICE option.
+Bugs: #412421
+
+--- cpulimit-1.1.orig/cpulimit.c
++++ cpulimit-1.1/cpulimit.c
+@@ -42,6 +42,7 @@
+ #include <dirent.h>
+ #include <errno.h>
+ #include <string.h>
++#include <limits.h> //for INT_MAX, could also hardcode some large number
+ //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!)
+@@ -59,6 +60,8 @@
+ int verbose=0;
+ //lazy mode
+ int lazy=0;
++//is higher priority nice possible?
++int nice_lim;
+ //reverse byte search
+ void *memrchr(const void *s, int c, size_t n);
+@@ -71,7 +74,7 @@
+ int waitforpid(int pid) {
+       //switch to low priority
+-      if (setpriority(PRIO_PROCESS,getpid(),19)!=0) {
++      if (nice_lim < INT_MAX && setpriority(PRIO_PROCESS,getpid(),19)!=0) {
+               printf("Warning: cannot renice\n");
+       }
+@@ -127,8 +130,8 @@
+ done:
+       printf("Process %d detected\n",pid);
+       //now set high priority, if possible
+-      if (setpriority(PRIO_PROCESS,getpid(),-20)!=0) {
+-              printf("Warning: cannot renice.\nTo work better you should run this program as root.\n");
++      if (nice_lim < INT_MAX && setpriority(PRIO_PROCESS,getpid(),nice_lim)!=0) {
++              printf("Warning: cannot renice.\n");
+       }
+       return 0;
+@@ -143,7 +146,7 @@
+ int getpidof(const char *process) {
+       //set low priority
+-      if (setpriority(PRIO_PROCESS,getpid(),19)!=0) {
++      if (nice_lim < INT_MAX && setpriority(PRIO_PROCESS,getpid(),19)!=0) {
+               printf("Warning: cannot renice\n");
+       }
+@@ -219,8 +222,8 @@
+ done:
+       printf("Process %d detected\n",pid);
+       //now set high priority, if possible
+-      if (setpriority(PRIO_PROCESS,getpid(),-20)!=0) {
+-              printf("Warning: cannot renice.\nTo work better you should run this program as root.\n");
++      if (nice_lim < INT_MAX && setpriority(PRIO_PROCESS,getpid(),nice_lim)!=0) {
++              printf("Warning: cannot renice.\n");
+       }
+       return pid;
+@@ -373,6 +376,7 @@
+       int pid_ok=0;
+       int process_ok=0;
+       int limit_ok=0;
++      struct rlimit maxlimit;
+       do {
+               next_option = getopt_long (argc, argv, short_options,long_options, NULL);
+@@ -437,6 +441,35 @@
+       signal(SIGINT,quit);
+       signal(SIGTERM,quit);
++      //now test high priority
++      if (setpriority(PRIO_PROCESS,getpid(),-20)!=0) {
++              //if that failed, check if we have a limit by how much we can raise the priority
++#ifdef RLIMIT_NICE //check if non-root can even make changes (ifdef because it's only available in linux >= 2.6.13)
++              nice_lim=getpriority(PRIO_PROCESS,getpid());
++              getrlimit(RLIMIT_NICE, &maxlimit);
++
++              if( (20 - (signed)maxlimit.rlim_cur) < nice_lim &&  //if we can do better then current
++                  setpriority(PRIO_PROCESS,getpid(),20 - (signed)maxlimit.rlim_cur)==0 //and it actually works
++                ) {
++
++                      //if we can do better, but not by much, warn about it
++                      if( (nice_lim - (20 - (signed)maxlimit.rlim_cur)) < 9) {
++                              printf("Warning, can only increase priority by %d.\n", nice_lim - (20 - (signed)maxlimit.rlim_cur));
++                      }
++
++                      nice_lim = 20 - (signed)maxlimit.rlim_cur; //our new limit
++
++              } else //otherwise don't try to change priority. The below will also run if it's not possible for non-root to change priority
++#endif
++              {
++                      printf("Warning: cannot renice.\nTo work better you should run this program as root, or adjust RLIMIT_NICE.\nFor example in /etc/security/limits.conf add a line with: * - nice -10\n\n");
++                      nice_lim=INT_MAX;
++              }
++      } else {
++              nice_lim=-20;
++      }
++      //don't bother putting setpriority back down, since getpidof and waitforpid twiddle it anyway
++
+       //time quantum in microseconds. it's splitted in a working period and a sleeping one
+       int period=100000;
+       struct timespec twork,tsleep;   //working and sleeping intervals
diff --git a/debian/patches/02_segfault_longoptions.patch b/debian/patches/02_segfault_longoptions.patch
new file mode 100644 (file)
index 0000000..ee21484
--- /dev/null
@@ -0,0 +1,27 @@
+Author: Cesare Tirabassi <norsetto@ubuntu.com>
+Description: Fix long options list of arguments.
+Bugs: #487233, #487236, LP #241538
+
+--- cpulimit-1.1.orig/cpulimit.c
++++ cpulimit-1.1/cpulimit.c
+@@ -360,13 +360,13 @@
+       const char* short_options="p:e:P:l:vzh";
+       /* An array describing valid long options. */
+       const struct option long_options[] = {
+-              { "pid", 0, NULL, 'p' },
+-              { "exe", 1, NULL, 'e' },
+-              { "path", 0, NULL, 'P' },
+-              { "limit", 0, NULL, 'l' },
+-              { "verbose", 0, NULL, 'v' },
+-              { "lazy", 0, NULL, 'z' },
+-              { "help", 0, NULL, 'h' },
++              { "pid", required_argument, NULL, 'p' },
++              { "exe", required_argument, NULL, 'e' },
++              { "path", required_argument, NULL, 'P' },
++              { "limit", required_argument, NULL, 'l' },
++              { "verbose", no_argument, NULL, 'v' },
++              { "lazy", no_argument, NULL, 'z' },
++              { "help", no_argument, NULL, 'h' },
+               { NULL, 0, NULL, 0 }
+       };
+       //argument variables
diff --git a/debian/patches/03_Makefile.patch b/debian/patches/03_Makefile.patch
new file mode 100644 (file)
index 0000000..0e2c9a5
--- /dev/null
@@ -0,0 +1,16 @@
+Author: Cesare Tirabassi <norsetto@ubuntu.com>
+Description: allow to pass CFLAGS from debian/rules
+
+--- cpulimit-1.1.orig/Makefile
++++ cpulimit-1.1/Makefile
+@@ -1,7 +1,9 @@
++CFLAGS?=-Wall -O2
++
+ all:: cpulimit
+ cpulimit:     cpulimit.c
+-      gcc -o cpulimit cpulimit.c -lrt -Wall -O2
++      gcc -o cpulimit cpulimit.c -lrt $(CFLAGS)
+ clean:
+       rm -f *~ cpulimit
diff --git a/debian/patches/04_opendir_leak.patch b/debian/patches/04_opendir_leak.patch
new file mode 100644 (file)
index 0000000..2c6b098
--- /dev/null
@@ -0,0 +1,33 @@
+Author: Johan Walles <johan.walles@gmail.com>
+Bug-Debian: http://bugs.debian.org/564517
+Description: Each time cpulimit finds a process to limit, it does a goto
+ past the call to closedir(). Plug that leak.
+Forwarded: yes
+Origin: vendor, cf. bug
+Reviewed-By: gregor herrmann <gregoa@debian.org>
+Last-Update: 2010-01-11
+
+--- a/cpulimit.c
++++ b/cpulimit.c
+@@ -98,6 +98,10 @@
+                               //pid detected
+                               if (kill(pid,SIGSTOP)==0 &&  kill(pid,SIGCONT)==0) {
+                                       //process is ok!
++                                      if (closedir(dip) == -1) {
++                                              perror("closedir");
++                                              return -1;
++                                      }
+                                       goto done;
+                               }
+                               else {
+@@ -188,6 +192,10 @@
+                                       if (found==1) {
+                                               if (kill(pid,SIGSTOP)==0 &&  kill(pid,SIGCONT)==0) {
+                                                       //process is ok!
++                                                      if (closedir(dip) == -1) {
++                                                              perror("closedir");
++                                                              return -1;
++                                                      }
+                                                       goto done;
+                                               }
+                                               else {
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644 (file)
index 0000000..a8afbb7
--- /dev/null
@@ -0,0 +1,4 @@
+01_priority.patch
+02_segfault_longoptions.patch
+03_Makefile.patch
+04_opendir_leak.patch
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..749e624
--- /dev/null
@@ -0,0 +1,4 @@
+#!/usr/bin/make -f
+
+%:
+       dh --with quilt $@
diff --git a/debian/watch b/debian/watch
new file mode 100644 (file)
index 0000000..87db4f8
--- /dev/null
@@ -0,0 +1,2 @@
+version=3
+http://sf.net/cpulimit/cpulimit-(.+)\.tar\.gz