cpulimit

Upgrading

Log lines, exit statuses and the options -p -e -l -c -i -m -v -z are unchanged from the original, so existing scripts keep working. These are the differences a script or an operator can notice.

From 1.0.2 to 1.0.3

  • Nothing to change. Options, exit statuses and log text are the same, and the controller is the same.
  • FreeBSD: -i now limits the whole tree. It used to limit only the direct children of the target, so grandchildren ran free. If you relied on that, limit the child you want by pid instead.
  • New systems: OpenBSD and NetBSD build and run; see Platforms for how far each is tested.

From the original cpulimit (0.2.x, 0.3.2)

AreaOriginal1.x
Option valuesatoi: -l 5x and -l abc were accepted, and -m could crashstrict parsing with ranges; -c 0 and -c 1000000 or more are rejected instead of spinning or failing in nanosleep
Command modea separate limiter process that could outlive its parentone process; the exit status is the command's
Two limiters, one targetallowed; they undo each other's SIGSTOP/SIGCONTthe second is refused (exit 1) and names the first; --no-lock restores the old behaviour
Process identitypid only: a reused pid was limited as if it were the targetpid and start time
Signalshandled in the handler; a signal could be lost before the waitflag-only handler; signals blocked except inside pselect()
Clockwall clockCLOCK_MONOTONIC
New optionsnone-d, -s, -P, --no-lock, --no-boost, -V, and long options for all
Buildrecursive Makefiles, Travis CIone Makefile, GitHub Actions

Control accuracy is the same: both versions use one controller, and both under-deliver at low limits and overshoot near 50 %. The gain is the lower cost of the limiter itself (measurements).

Checking an upgrade

cpulimit -V                                 # version
cpulimit -l 50 -- sh -c 'exit 7'; echo $?   # 7: the command's status is passed through
cpulimit -l 5x -p 1234 ; echo $?            # 1: strict option parsing