Giter Site home page Giter Site logo

cpulimit's People

Contributors

dt1973 avatar heldermagalhaes avatar opsengine avatar urdh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cpulimit's Issues

i find -e option does not work on my ubuntu,and i think i find the reason

in process_iterator_linux.c function: int close_process_iterator(struct process_iterator_)
this function's return value 0 when sucessful,and 1 when it error.then,
in process_group.c function:int find_process_by_name(const char_)
it has:
if(close_process_iterator(&it) != 1)exit(1);<-------------------------i think it should be:
if(close_process_iterator(&it) != 0)exit(1);
and after i fix it,the program works well!!~
so ,check it out..and thanks.

Why not include usage doc in README?

command:

./cpulimit -h 

ouput:

Usage: cpulimit [OPTIONS...] TARGET
   OPTIONS
      -l, --limit=N          percentage of cpu allowed from 0 to 800 (required)
      -v, --verbose          show control statistics
      -z, --lazy             exit if there is no target process, or if it dies
      -i, --include-children limit also the children processes
      -h, --help             display this help and exit
   TARGET must be exactly one of these:
      -p, --pid=N            pid of the process (implies -z)
      -e, --exe=FILE         name of the executable program file or path name
      COMMAND [ARGS]         run this command and limit it (implies -z)

Report bugs to <[email protected]>.

Why not include this usage doc in README?

cpuLimit *itself* uses some 5% of my CPU - per cpuLimit process

cpulimit -l 90 -i -e cli > /dev/null 2>&1 &
cpulimit -l 150 -i -e gdebi > /dev/null 2>&1 &

creates two processes, each of which uses between 4% and 6% of the total processing power of my dual-core CPU.

I am using the latest version of cpulimit - from here on GitHub.

Mint 18.2. x64 Cinnamon

Assertion `tmp_process.starttime == p->starttime' failed

Command: cpulimit -i -l 20 php test.php
O.S: Ubuntu 12.04.5 LTS
Error:
cpulimit: process_group.c:175: update_process_group: Assertion `tmp_process.starttime == p->starttime' failed

¿Can i bring any other info to help get this fixed?

Unsafe use of sscanf

cppcechek output:

[src/process_iterator_linux.c:106]: (warning) scanf without field width limits can crash with huge input data.

I think the cpp check output is self explanatory.
Please let me know if I can help with any other issues. Always glad to help out.

Waiting for multiple process instances

Hi,

I'm putting this here because I don't have the option to create a new Pull Request.

I posted this in the Plex forums here: http://forums.plexapp.com/index.php/topic/48179-cpulimit/

But, I thought it would be a good idea to go to the source and ask the developers!

Here is a copy of what I posted there:

I would like to have CPUlimit run and apply the limit to any instance of a PID individually.

Here is my command: $ sudo cpulimit --exe "/usr/lib/plexmediaserver/Resources/Plex Transcoder" --limit 99

Effectively, this allows me to limit (1) Plex transcoding instance to roughly one core of the server I'm testing with. I would like to be able to have CPUlimit apply to any future instance of the process. We are trying to see just how many transcoding streams we can run on one server. So far, without CPUlimit, we can run 5ish 720P(3mbps) transcoding streams (from 1080p) with each process running between 300-600% before it starts juggling them and begins to buffer on the clients.

I have successfully been able to run one instance of the transcoder set with CPUlimit at 99% and playback was very smooth on the client.

I can also run more than one stream and limit each stream manually using multiple instances of CPUlimit and the individual process IDs -- this is what i would like to avoid.

Any suggestions?

AND THANK YOU!

Multiple instances?

When I issue a cpulimit for a certain process, and later on decide to use a different limit for the same (still running) process and issue another cpulimit, then both these cpulimit processes are running at the same time. Is this desirable? What happens??

How to change the limit % on the fly

is it a way to change the limit % on the fly? Lets say I need a process uses 90% of CPU in non-working hours, but 15% in working hours.

Without killing the process, how should we do that?

cpulimit hang - ignore children

Dears,

In our using scenario, we need to use ignore-children. Otherwise, it would send SIGSTOP to itself.
And we found in the latest code, one parameter was passing incorrectly.
void limit_process(pid_t pid, double limit, int include_children);
I think it should be
void limit_process(pid_t pid, double limit, int ignore_children);

Thanks,
Blacat

Child process does not respect the limit

The readme reads

All the children processes and threads of the specified process will share the same percentage of CPU.

however,

#include <unistd.h>

int main(int argc, char *argv[])
{
    fork();
    while (1) {
    }
    return 0;
}
gcc test.c
cpulimit -l 10 ./a.out
  PID USER      PR  NI    VIRT    RES %CPU %MEM     TIME+ S COMMAND                                                                       
 9553 root      20   0    3.9m   0.1m 88.8  0.0   0:07.30 R a.out                                                                         
 9551 root      20   0    3.9m   0.6m  9.9  0.1   0:00.98 T a.out 

Linux arch03 4.8.13-1-ARCH #1 SMP PREEMPT Fri Dec 9 07:24:34 CET 2016 x86_64 GNU/Linux

Not affecting child processes

I noticed (also tested myself with two scripts of my own making, also making sure with "ps axf" the first one was a parent of the second), that if I launch a program with: cpulimit -l NN program_1 and program_1 launches program_2, then the limit will not apply to program_2 as stated somewhere in the docs (that all programs in the tree will cumulatively not exceed the limit with which program_1 was launched).

Is this a bug, or am I doing something wrong?

Can cpulimit be used for the simulation of cpu usgae?

Actually I need to simulate cpu usage for testing purpose. I need varied usage over the fixed span of time for testing one of my program. Like 40% usage for 10 minutes then 60%usage for next 20 minutes then 10% for 5 minutes and so on. And then I need the same cpu usage multiple times for testing performance of my program using different modes. Is it achievable using cpulimit? If yes let me know commands by which I can perform the same.

OSX Lion 'Invalid value for argument PID'

I have compiled the HEAD version of cpulimit and running it with "cpulimit -p 71217 -l 30" results in the following error:

Error: Invalid value for argument PID
Usage: cpulimit [OPTIONS...] TARGET
   OPTIONS
      -l, --limit=N          percentage of cpu allowed from 0 to 800 (required)
      -v, --verbose          show control statistics
      -z, --lazy             exit if there is no target process, or if it dies
      -i, --ignore-children  don't limit children processes
      -h, --help             display this help and exit
   TARGET must be exactly one of these:
      -p, --pid=N            pid of the process (implies -z)
      -e, --exe=FILE         name of the executable program file or path name
      COMMAND [ARGS]         run this command and limit it (implies -z)

Report bugs to <[email protected]>.

Using -e works, and running it with COMMAND [ARGS] also works. It is only using it with -p that doesn't.

cpulimit running into strange state, where "active rate" is approaching "-inf%" and cpulimit is consuming 100% cpu

Not only it's approaching -inf%, but also cpulimit's cpu consumption jumps in such case from ~8-%16% up to 100% cpu !!! (What's ridiculous -> limiting another process in order to consume much more in total...)

~$ cpulimit -l 120 -v -i -p 1093
4 cpu detected
Process 1093 found
Priority changed to -10
Members in the process group owned by 1093: 62

%CPU    work quantum    sleep quantum   active rate
65.97%  -4978022 us     5078022 us      -4978.02%
69.12%  -4204714017 us  4204814017 us   -4204714.02%
58.72%  -1547879850491 us       1547879950491 us        -1547879850.49%
43.83%  -7211417519573343 us    7211417519673343 us     -7211417519573.34%
151.28% -9223372036854775 us    -9223372036754775 us    -27660332491476.79%
118.45% -9223372036854775 us    -9223372036754775 us    -11637563745761.26%
98.92%  -9223372036854775 us    -9223372036754775 us    -36331706976137.16%
77.73%  -9223372036854775 us    -9223372036754775 us    -968682548848361.50%
63.99%  -9223372036854775 us    -9223372036754775 us    -211598787888799072.00%
54.89%  -9223372036854775 us    -9223372036754775 us    -236746047257026953216.00%
64.74%  -9223372036854775 us    -9223372036754775 us    -482714412824172924239872.00%
64.54%  -9223372036854775 us    -9223372036754775 us    -197557354683614243187589120.00%
60.49%  -9223372036854775 us    -9223372036754775 us    -119454361302601496968055226368.00%
51.32%  -9223372036854775 us    -9223372036754775 us    -352818752303218465241932972949504.00%
47.28%  -9223372036854775 us    -9223372036754775 us    -3822248099277363188979371941308661760.00%
58.17%  -9223372036854775 us    -9223372036754775 us    -6291685230715492091145178890211822665728.00%
45.02%  -9223372036854775 us    -9223372036754775 us    -40402531469308858601015182445184936954560512.00%
41.43%  -9223372036854775 us    -9223372036754775 us    -607317760862129038088473195155531427862793945088.00%
60.24%  -9223372036854775 us    -9223372036754775 us    -2097714956318316238517237210820216713485385600073728.00%

(...)
~$ cpulimit -l 120 -v -i -p 1093
4 cpu detected
Process 1093 found
Priority changed to -10
Members in the process group owned by 1093: 62

%CPU    work quantum    sleep quantum   active rate
65.97%  -4978022 us     5078022 us      -4978.02%
69.12%  -4204714017 us  4204814017 us   -4204714.02%
58.72%  -1547879850491 us       1547879950491 us        -1547879850.49%
43.83%  -7211417519573343 us    7211417519673343 us     -7211417519573.34%
151.28% -9223372036854775 us    -9223372036754775 us    -27660332491476.79%
118.45% -9223372036854775 us    -9223372036754775 us    -11637563745761.26%
98.92%  -9223372036854775 us    -9223372036754775 us    -36331706976137.16%
77.73%  -9223372036854775 us    -9223372036754775 us    -968682548848361.50%
63.99%  -9223372036854775 us    -9223372036754775 us    -211598787888799072.00%
54.89%  -9223372036854775 us    -9223372036754775 us    -236746047257026953216.00%
64.74%  -9223372036854775 us    -9223372036754775 us    -482714412824172924239872.00%
64.54%  -9223372036854775 us    -9223372036754775 us    -197557354683614243187589120.00%
60.49%  -9223372036854775 us    -9223372036754775 us    -119454361302601496968055226368.00%
51.32%  -9223372036854775 us    -9223372036754775 us    -352818752303218465241932972949504.00%
47.28%  -9223372036854775 us    -9223372036754775 us    -3822248099277363188979371941308661760.00%
58.17%  -9223372036854775 us    -9223372036754775 us    -6291685230715492091145178890211822665728.00%
45.02%  -9223372036854775 us    -9223372036754775 us    -40402531469308858601015182445184936954560512.00%
41.43%  -9223372036854775 us    -9223372036754775 us    -607317760862129038088473195155531427862793945088.00%
60.24%  -9223372036854775 us    -9223372036754775 us    -2097714956318316238517237210820216713485385600073728.00%

Segmentation fault

I'm using CentOS 5.8 with kernel Linux 2.6.18-308.16.1.el5xen (VDS).
And I urgently need to cut CPU for mysqld but cpulimit goes in Segmentation fault after a some time of running. I tried both developer and master releases of cpulimit.

My startup is: cpulimit -e mysqld -l 85
Host provider says next info: Processor information Intel(R) Xeon(R) CPU L5420 @ 2.50GHz, 4 cores

But I am not sure that all 4 cores are in use because when mysql uses (if look in top, cpu column) >100%, server lags insanely.

Scope of variable "cp" can be reduced

cppcheck output:

[src/memrchr.c:29]: (style) The scope of the variable 'cp' can be reduced.

The variable cp is not used outside the if block. Declaring it outside of the block extends it's scope unecessarily.

It would be better if the variable were to be declared inside the if block.

cpulimit dies with assertion failure

98.81%   10744 us    89255 us   10.74%
44.02%     944 us    99055 us   0.94%
28.69%  100000 us        0 us   100.00%
5.15%   100000 us        0 us   100.00%
SIGCONT failed. Process 19354 dead!
cpulimit: process_group.c:175: update_process_group: Assertion `tmp_process.starttime == p->starttime' failed.

What does this error mean? Is it an error in cpulimit?

Send to background

There isn't any flag to send the process to background which isn't ideal.

Not detect whether the value of workingrate is legal (0~1).This is a bug!!

Not detect whether the value of workingrate is legal (0~1).This is a bug!!
workingrate=-1
%CPU work quantum sleep quantum active rate
10.47% -6116737 us 6216737 us -6116.74%
7.50% -24684377433 us 24684477433 us -24684377.43%
5.84% -1560724484509556 us 1560724484609556 us -1560724484509.56%
20.04% -9223372036854775 us -9223372036754775 us -1498921050589318.75%

Does it works?

Hi.

My simple question is - does it really works? I've tried to use cpulimit many times, few years ago, and now. Just playing on virtual machines (KVM virtualization). Always i see the same issue - it does not work. CPU used by target process stay the same or become more, also the application itself become hell slow - it should be OK with working limit, but the CPU usage don't changed... Also there are new cpulimit process, which also uses some cpu.
So i have slow down on the target app/process and increased CPU usage.

I'm testing on Debian 7 x86. I've tried cpulimit version from apt (from 2012) and current git version, results are very similar.

cpulimit --limit=1 -v -p 16446
4 cpu detected
Process 16446 found
Priority changed to -10
Members in the process group owned by 16446: 1

%CPU    work quantum    sleep quantum   active rate
14.78%       0 us        99999 us       0.00%
9.58%        0 us       100000 us       0.00%
21.65%       0 us       100000 us       0.00%
11.95%       0 us       100000 us       0.00%
28.41%       0 us       100000 us       0.00%
24.07%       0 us       100000 us       0.00%
29.12%       0 us       100000 us       0.00%
31.57%       0 us       100000 us       0.00%
17.59%       0 us       100000 us       0.00%
22.53%       0 us       100000 us       0.00%
20.43%       0 us       100000 us       0.00%
36.58%       0 us       100000 us       0.00%
29.90%       0 us       100000 us       0.00%
24.63%       0 us       100000 us       0.00%
126.17%      0 us       100000 us       0.00%
57.77%       0 us       100000 us       0.00%
27.19%       0 us       100000 us       0.00%
25.82%       0 us       100000 us       0.00%
12.16%       0 us       100000 us       0.00%
22.74%       0 us       100000 us       0.00%

I expect "%CPU" here to be 1.00% or not more than 10.00%. But it's always high. I also, sure, monitor CPU usage by other tools, like top. And result is same - high usage.

16446 root      20   0 1523m 191m 4632 T  41,2 19,0   3860:03 mysqld

41,2% - cpu load here.

What did i miss?

"Process found but you aren't allowed to control it" exits with code 0

The error "Process found but you aren't allowed to control it" should exit with an error code.

To reproduce, just call it using -p with some PID not belonging to you.

My idea is to be able to wait for a process by iteratively executing cpulimit until it returns true. This asumes any case when the process is not found, the return code will be different than 0. Do you find that assumption reasonable?

Thanks in advance!

Error

Hi,
I got the compiled version and it works splendid on my iMac (i5, 2.7Ghz, 27" 8GB). I want to use this on my Mac Mini to prevent the heating up/high fanspeed.

However on the Mini (i7, 20.Ghz, 8GB) when it is started it return "Illegal Instruction: 4".

Can I do something to solve this?

gr,
Ton

Not detecting process cpu usage?

After a recent update to an application, cpulimit no longer seems to work (on that app). The process is using 300% (it's natual state) and cpulimit reports zero usage ... and presumably as a result is not slowing it down.

ickis:/srv/plex # ./cpulimit -v -i -l 80 -p 15767
4 cpu detected
Process 15767 found
Priority changed to -10
Members in the process group owned by 15767: 1

%CPU    work quantum    sleep quantum   active rate
0.00%   100000 us        0 us   100.00%
0.00%   100000 us        0 us   100.00%
0.00%   100000 us        0 us   100.00%
0.00%   100000 us        0 us   100.00%
0.00%   100000 us        0 us   100.00%
0.00%   100000 us        0 us   100.00%

If I file a bug report with the process' author, can you give me any info as to what change they could have implemented that would cause this behavior?

Disk ARchive (DAR)

How can I limit DAR so that DAR doesn't exit its process? What happens is that the shell acts as though DAR has been killed.

What happens is:

root@dur:#
root@dur:
# dar -c /home/thufir/Desktop/thufir2012dec25 -s 880M -p -b -z -R /media/sda2/home/thufir/
[1]+ Stopped dar -c /home/thufir/Desktop/thufir2012dec25 -s 880M -p -b -z -R /media/sda2/home/thufir/
root@dur:~#

wheras it should stay "open" on the terminal for user input. Instead, it exits dar, as dar seems stopped.

See also:

http://article.gmane.org/gmane.comp.sysutils.backup.dar.support/2640

thanks,

Thufir

ps: no mailing list?

Missing manual page

Currently the program does not have a manual page, giving basic information on how to use the it. It would be useful to add a manual page, as it would allow users to more easily figure out how to use the program.

Address boundary error

Here is what I get:

root@peace /h/ciembor# cpulimit --pid 7324 --limit 80
fish: Job 1, 'cpulimit --pid 7324 --limit 80' terminated by signal SIGSEGV (Address boundary error)

I have x86_64 ArchLinux package.

Using uninitialized variable

cppcheck output:

[src/process_iterator_linux.c:41]: (error) Uninitialized variable: uptime

Since the variable uptime is not initialized in line 26, there is a way to reach line 41 and use it's value without ever initializing it.

Document exit codes

It would be great to somehow know which error code indicates which kind of failure. As in
1 = pid does not exist
2 = permission denied
3 = syntax / option parsing error
The above are dummy values. I just got exit code 2 and I have no idea what it means.
Invalid parameters like cpulimit abc should also finish with a non-zero code, which they dont.
Regards,

edit. it seems that error code 2 occurs when the executable has finished and ALSO when there was no process found at all. However, it always results in 0 if used together with -b. Is this really intended?

cpulimit doesn't handle multi core systems

I'm using handbrake to test cpulimit.

If I run

$ sudo cpulimit -p 6034 -l 99

the process is throttled.

If I run

$ sudo cpulimit -p 6034 -l 100

the process is not throttled and runs full bore.

I read that a quad core cpu should accept values up to 400%. Is this true?

Thanks

cpulimit hangs after executing command

Hi there,

i've a problem with cpulimit.

Example Usage:

./cpulimit -l 10 echo "Hello World"

Result: cpulimit hangs

After a friendly STRG c i got the following result:

zsh: segmentation fault  ./cpulimit -l 10 echo "Hello World"

Usage with verbose mode:

./cpulimit -v -l 10 echo "Hello World"

Result:

8 cpu detected
Running command: 'echo Hello World'
Limiting process 6578
Warning: Cannot change priority. Run as root or renice for best results.
Members in the process group owned by 6578: 1

%CPU    work quantum    sleep quantum   active rate
Hello World
Process 6578 dead!
Process 6578 dead!
Process 6578 dead!
Process 6578 dead!
Process 6578 dead!
Process 6578 dead!
Process 6578 dead!
Process 6578 dead!
Process 6578 dead!
Process 6578 dead!
0.00%   100000 us            0 us       100.00%
Process 6578 dead!
Process 6578 dead!
Process 6578 dead!
Process 6578 dead!
Process 6578 dead!
Process 6578 dead!
Process 6578 dead!
Process 6578 dead!
Process 6578 dead!
Process 6578 dead!
0.00%   100000 us            0 us       100.00%
Process 6578 dead!
Process 6578 dead!
Process 6578 dead!
Process 6578 dead!

Endless output.

I think that is not the expected behavior.

The cpulimt version is the actual master branch.

git rev-parse HEAD
d7373dde5dde22945524d09e2c3f7f1a8290c6b9

Could that be the solution?

diff --git a/src/cpulimit.c b/src/cpulimit.c
index 5353b90..92ab156 100644
--- a/src/cpulimit.c
+++ b/src/cpulimit.c
@@ -231,7 +231,8 @@ void limit_process(pid_t pid, double limit, int include_children)
                        if (kill(proc->pid,SIGCONT)!=0) {
                                //process is dead, remove it from family
                                if (verbose) fprintf(stderr, "Process %d dead!\n", proc->pid);
-                               //remove_process_from_family(&pf, proc->pid);
+                               delete_node(pgroup.proclist, node);
+                               destroy_node(pgroup.proclist, node);
                        }
                }

@@ -254,7 +255,8 @@ void limit_process(pid_t pid, double limit, int include_children)
                                if (kill(proc->pid,SIGSTOP)!=0) {
                                        //process is dead, remove it from family
                                        if (verbose) fprintf(stderr,"Process %d dead!\n", proc->pid);
-                                       //remove_process_from_family(&pf, proc->pid);
+                                       delete_node(pgroup.proclist, node);
+                                       destroy_node(pgroup.proclist, node);
                                }
                        }
                        //now the processes are sleeping

php with cpulimit

Hi

I try to run a php script with cpulimit but, cpulimit always stop the script and the process still visible with "top" command ... just like 0 %CPU 0 %MEM

I try

./_cpulimit/cpulimit -l 90 -z -v "php /home/test/test.php"

but get

2 cpu detected
Running command: 'php /home/test/test.php'
Error: No such file or directory
Limiting process 23875
Priority changed to -10
Members in the process group owned by 23875: 1

%CPU    work quantum    sleep quantum   active rate
Process 23875 dead!
Process 23875 dead!
Process 23875 dead!
Process 23875 dead!
Process 23875 dead!
Process 23875 dead!
Process 23875 dead!
Process 23875 dead!
Process 23875 dead!
Process 23875 dead!
Process 23875 dead!
0.00%   100000 us            0 us       100.00%

if i just run

php /home/test/test.php

It's work fine.

I try to put in my php file

exec( "/home/test/_cpulimit/cpulimit -l 90 -v -z -p " . getmypid() );

but get

[2]+  Stopped                 php /home/test/test.php

I don't really understand where the problem is ...
If you can help me ?

Thanks,
RemRem

Not used attribution

cppcheck output:

[src/list.c:69]: (warning) Assignment of function parameter has no effect outside the function.

Assigning NULL to the node pointer will not have any effect outside the function, since the variable will be destroyed when the function terminates. Removing the line 69 would improve performance.

-e or --exe option not working

I'm using arch linux with x64 kernel 3.5.3-1-ARCH

When I try to use the -e or --exe options, cpulimit exits.

$ cpulimit -l 50 -e urxvt -v
2 cpu detected

$ cpulimit -l 50 --exe=urxvt -v
2 cpu detected

On the current Master Branch:

commit 49d7c69
Merge: 9df7758 f209b18
Author: Angelo Marletta [email protected]
Date: Thu Jul 5 16:05:22 2012 -0700

cpulimit - fgets () - Segmentation fault.

cpulimit got segmentation fault on fgets call.

%----backtrace
# Backtrace
[New Thread 1321]
[Thread debugging using libthread_db enabled]
Core was generated by `/usr/bin/cpulimit -e gzip -l 50'.
Program terminated with signal 11, Segmentation fault.
\#0  0x00007fbd5c48fcad in fgets () from /lib64/libc.so.6

Thread 1 (Thread 0x7fbd5cbd9700 (LWP 1321)):
\#0  0x00007fbd5c48fcad in fgets () from /lib64/libc.so.6
No symbol table info available.
\#1  0x0000000000402c0f in read_process_info ()
No symbol table info available.
\#2  0x0000000000402ea2 in get_next_process ()
No symbol table info available.
\#3  0x0000000000403026 in find_process_by_name ()
No symbol table info available.
\#4  0x00000000004022c9 in main ()
No symbol table info available.
From                To                  Syms Read   Shared Object Library
0x00007fbd5c7c2130  0x00007fbd5c7c6e18  Yes         /usr/lib64/libsnoopy.so
0x00007fbd5c447aa0  0x00007fbd5c568f4c  Yes (*)     /lib64/libc.so.6
0x00007fbd5c211760  0x00007fbd5c21d0c8  Yes (*)     /lib64/libpthread.so.0
0x00007fbd5c008de0  0x00007fbd5c009998  Yes (*)     /lib64/libdl.so.2
0x00007fbd5c9cab00  0x00007fbd5c9e3a8b  Yes (*)     /lib64/ld-linux-x86-64.so.2
(gdb) info frame
Stack level 0, frame at 0x7fffdeeab280:
 rip = 0x7f243f1b7cad in _IO_fgets (iofgets.c:52); saved rip 0x402c0f
 called by frame at 0x7fffdeeab300
 source language c.
 Arglist at 0x7fffdeeab258, args: buf=0x604fc0 "3439", n=1024, fp=0x0
 Locals at 0x7fffdeeab258, Previous frame's sp is 0x7fffdeeab280
 Saved registers:
  rbx at 0x7fffdeeab260, rbp at 0x7fffdeeab268, r12 at 0x7fffdeeab270, rip at 0x7fffdeeab278

(gdb) info args
buf = 0x604fc0 "3439"
n = 1024
fp = 0x0
Thread 1 (Thread 0x7f243f901700 (LWP 1321)):
\#0  _IO_fgets (buf=0x604fc0 "3439", n=1024, fp=0x0) at iofgets.c:52
        _IO_acquire_lock_file = 0x0
        count = <value optimized out>
        result = <value optimized out>
        old_error = <value optimized out>
\#1  0x0000000000402c0f in read_process_info ()
No symbol table info available.
\#2  0x0000000000402ea2 in get_next_process ()
No symbol table info available.
\#3  0x0000000000403026 in find_process_by_name ()
No symbol table info available.
\#4  0x00000000004022c9 in main ()
No symbol table info available.

It seems due missing "if (fd==NULL)" in read_process_info function while reading command line.

Patch:

--- src-o/process_iterator_linux.c
+++ src/process_iterator_linux.c
@@ -98,6 +98,7 @@
    //read command line
    sprintf(exefile,"/proc/%d/cmdline", p->pid);
    fd = fopen(exefile, "r");
+   if (fd==NULL) return -1;
    if (fgets(buffer, sizeof(buffer), fd)==NULL) {
        fclose(fd);
        return -1;

Assertion tmp process failed

Good morning!

Running $ cpulimit -l 240 python myscript.py
on a quad-core debian
with the master branch at this date
After 20 minutes, I get:

cpulimit: process_group.c:203: update_process_group: Assertion `tmp_process.ppid == p->ppid' failed. 

myscript.py runs 60 to 120 child process.

Any clue how to fix that?

Thank you,
Emmanuel

[feature request] OS X is there a way to limit using process name instead of pid?

Hey,

First off, thank you, awesome script/program! I have been using it while I was on a linux distro and now on a mac.

My query really is, is it possible to limit a process on the mac using the name of the program.

Scenario:
I mainly use Cpulimit to limit the CPU usage of Handbrake on my mac. I keep having to encode a lot of videos and Cpulimit helps a ton in doing its job.

However, after I finish converting a batch I exit both Cpulimit as well as Handbrake.
The next time I run Handbrake it obviously has a new pid. I then Have to edit the .command shortcut I made for Cpulimit and put in the new pid after checking the pid of HandBrake using the top command.

I would ideally like the shortcut to not have to be edited each time I launch Handbrake. I would like to just double click the Cpulimit shortcut to make it curb the Handbrake process by using the process name instead of the pid.

Example of my .command shortcut:
cd /Users/mymac/Library/Application\ Support/cpulimit/
./cpulimit --p 13827 --limit 77

^That works just fine but requires me to keep editing the pid

I tried:
./cpulimit --e HandBrake --limit 77
./cpulimit -P /Applications/Handbrake --limit 77

and other permutations and combinations before I realized that -e is meant for a .exe and not an .app

Could you please help me out in understanding if what I want is possible.
Thank you Sir.

Jake.

Process found but you aren't allowed to control it

I'm trying to limit CPU usage by cc1 and gcc compiles, but this is what I get. No matter if I run it with sudo or su.

$ cpulimit -l 10 -v -p 2083
2 cpu detected
Process found but you aren't allowed to control it

-e option not working on v0.2 installed by brew

I installed v0.2 with brew on OS X 10.8.5 and I could not get the -e option to work. I tried all the following

cpulimit -l 0 -v -z -i -e "Google Chrome"
cpulimit -l 0 -v -z -i -e "Google Chrome Helper"
cpulimit -l 0 -v -z -i -e "/Applications/Google Chrome 2.app/Contents/MacOS/Google Chrome"
cpulimit -l 0 -v -z -i -e "chrome"

and got

16 cpu detected
Segmentation fault: 11

Only the -p PID option worked

cpulimit -l 0 -v -z -i -p 1440

The PID is for the Google Chrome parent process.

Scope of variable "tmp" can be reduced

cppcheck output:

[src/list.c:126]: (style) The scope of the variable 'tmp' can be reduced.
[src/list.c:138]: (style) The scope of the variable 'tmp' can be reduced.

On both loops the variable tmp is not used outside the block, so it would be better to declare it inside the loop blocks.

cpulimit -e not catching all processes of that name

Hi!

I'm trying to limit pesky Google Chrome to around 25% CPU since it has a tendency to grind my PC to a halt.

I type 'cpulimit -e chrome -l 25', however it only monitors one process ID for CPU consumption, not all of name 'chrome'.

Many thanks,
Rob.

Assertion failed

I tried running process_iterator_test, and got:

Assertion failed: (tot_usage / i < 1.1 && tot_usage / i > 0.8), function test_process_group_single, file process_iterator_test.c, line 189.
Abort trap: 6

(on OS X 10.8)

Countless instances?

I've set up this tool using these instructions (http://ubuntuforums.org/showthread.php?t=992706)... however having done so and got it running I'm getting countless instances of the tool.

Is this normal? I can't see anything that I've done wrong - I've just set the script to run on boot and that's about it.

screen shot 2015-09-29 at 8 50 24 p m

Is this a common issue or have I just done something wrong?

Many thanks

Alex

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.