[~] Refactor
This commit is contained in:
parent
a988f394b5
commit
ce2fd89c28
5
deps/cpulimit-fork/.gitignore
vendored
Normal file
5
deps/cpulimit-fork/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
*.o
|
||||
*~
|
||||
src/cpulimit
|
||||
busy
|
||||
process_iterator_test
|
16
deps/cpulimit-fork/LICENSE
vendored
Normal file
16
deps/cpulimit-fork/LICENSE
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
cpulimit - a CPU usage limiter for Linux
|
||||
Copyright (C) 2005-2012, by: Angelo Marletta <angelo dot marletta at gmail dot com>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
8
deps/cpulimit-fork/Makefile
vendored
Normal file
8
deps/cpulimit-fork/Makefile
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
default: build
|
||||
|
||||
build:
|
||||
cd src && $(MAKE)
|
||||
cd tests && $(MAKE)
|
||||
|
||||
pacman: build
|
||||
cd pacman-package && makepkg -e -f
|
42
deps/cpulimit-fork/README.md
vendored
Normal file
42
deps/cpulimit-fork/README.md
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
CPULIMIT
|
||||
========
|
||||
|
||||
Cpulimit is a tool which limits the CPU usage of a process (expressed in percentage, not in CPU time). It is useful to control batch jobs, when you don't want them to eat too many CPU cycles. The goal is prevent a process from running for more than a specified time ratio. It does not change the nice value or other scheduling priority settings, but the real CPU usage. Also, it is able to adapt itself to the overall system load, dynamically and quickly.
|
||||
The control of the used CPU amount is done sending SIGSTOP and SIGCONT POSIX signals to processes.
|
||||
All the children processes and threads of the specified process will share the same percentage of CPU.
|
||||
|
||||
Developed by Angelo Marletta.
|
||||
Please send your feedback, bug reports, feature requests or just thanks.
|
||||
|
||||
|
||||
Get the latest source code
|
||||
--------------------------
|
||||
|
||||
The latest available code is here:
|
||||
|
||||
https://github.com/opsengine/cpulimit
|
||||
|
||||
|
||||
Install instructions
|
||||
--------------------
|
||||
|
||||
On Linux/OS X:
|
||||
|
||||
$ make
|
||||
# cp src/cpulimit /usr/bin
|
||||
|
||||
On FreeBSD:
|
||||
|
||||
$ gmake
|
||||
# cp src/cpulimit /usr/bin
|
||||
|
||||
Run unit tests:
|
||||
|
||||
$ ./tests/process_iterator_test
|
||||
|
||||
|
||||
Contributions
|
||||
-------------
|
||||
|
||||
You are welcome to contribute to cpulimit with bugfixes, new features, or support for a new OS.
|
||||
If you want to submit a pull request, please do it on the branch develop and make sure all tests pass.
|
19
deps/cpulimit-fork/pacman-package/.SRCINFO
vendored
Normal file
19
deps/cpulimit-fork/pacman-package/.SRCINFO
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
pkgbase = cpulimit-git
|
||||
pkgdesc = Limit cpu usage in %. Actualy sends SIGSTOP/SIGCONT
|
||||
pkgver = 113.f4d2682
|
||||
pkgrel = 1
|
||||
url = https://github.com/opsengine/cpulimit
|
||||
arch = i686
|
||||
arch = x86_64
|
||||
license = GPL
|
||||
makedepends = git
|
||||
depends = glibc
|
||||
provides = cpulimit
|
||||
conflicts = cpulimit
|
||||
source = cpulimit-git::git+https://github.com/opsengine/cpulimit.git
|
||||
source = patch
|
||||
md5sums = SKIP
|
||||
md5sums = 524d8ec2fa0d6f5c4e2f453929c94c3e
|
||||
|
||||
pkgname = cpulimit-git
|
||||
|
42
deps/cpulimit-fork/pacman-package/PKGBUILD
vendored
Normal file
42
deps/cpulimit-fork/pacman-package/PKGBUILD
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
# This is an example PKGBUILD file. Use this as a start to creating your own,
|
||||
# and remove these comments. For more information, see 'man PKGBUILD'.
|
||||
# NOTE: Please fill out the license field for your package! If it is unknown,
|
||||
# then please put 'unknown'.
|
||||
|
||||
# See http://wiki.archlinux.org/index.php/VCS_PKGBUILD_Guidelines
|
||||
# for more information on packaging from GIT sources.
|
||||
|
||||
# Maintainer: Mike Lenzen <lenzenmi@gmail.com>
|
||||
pkgname=cpulimit-git
|
||||
pkgver=1
|
||||
pkgrel=1
|
||||
pkgdesc="Limit cpu usage in %. Actualy sends SIGSTOP/SIGCONT"
|
||||
arch=('i686' 'x86_64')
|
||||
url="https://github.com/opsengine/cpulimit"
|
||||
license=('GPL')
|
||||
depends=('glibc')
|
||||
makedepends=('git')
|
||||
provides=('cpulimit')
|
||||
conflicts=('cpulimit')
|
||||
source=("patch")
|
||||
|
||||
md5sums=('SKIP'
|
||||
'524d8ec2fa0d6f5c4e2f453929c94c3e')
|
||||
|
||||
build() {
|
||||
rm $pkgname
|
||||
ln -sf $srcdir/../.. $pkgname
|
||||
cd "$srcdir/$pkgname"
|
||||
|
||||
make
|
||||
}
|
||||
|
||||
# Patch to remove sysctl.h - removed from linxu
|
||||
prepare() {
|
||||
cd "$srcdir/$pkgname"
|
||||
patch --forward --strip=1 --input="${srcdir}/patch"
|
||||
}
|
||||
|
||||
package() {
|
||||
install -D -m0755 $srcdir/$pkgname/src/cpulimit $pkgdir/usr/bin/cpulimit
|
||||
}
|
1
deps/cpulimit-fork/pacman-package/cpulimit-git
vendored
Symbolic link
1
deps/cpulimit-fork/pacman-package/cpulimit-git
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
/home/nartes/Documents/current/freelance-project-34-marketing-blog/deps/cpulimit-fork/pacman-package/..
|
BIN
deps/cpulimit-fork/pacman-package/cpulimit-git-1-1-x86_64.pkg.tar.zst
vendored
Normal file
BIN
deps/cpulimit-fork/pacman-package/cpulimit-git-1-1-x86_64.pkg.tar.zst
vendored
Normal file
Binary file not shown.
12
deps/cpulimit-fork/pacman-package/patch
vendored
Normal file
12
deps/cpulimit-fork/pacman-package/patch
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
Only in cpulimit-git: patch~
|
||||
diff --unified --recursive --text cpulimit-git/src/cpulimit.c cpulimit-git-patched/src/cpulimit.c
|
||||
--- cpulimit-git/src/cpulimit.c 2021-05-23 14:30:31.441532911 -0600
|
||||
+++ cpulimit-git-patched/src/cpulimit.c 2021-05-23 14:29:24.612229881 -0600
|
||||
@@ -38,7 +38,6 @@
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
-#include <sys/sysctl.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
654
deps/cpulimit-fork/pacman-package/pkg/cpulimit-git/.BUILDINFO
vendored
Normal file
654
deps/cpulimit-fork/pacman-package/pkg/cpulimit-git/.BUILDINFO
vendored
Normal file
@ -0,0 +1,654 @@
|
||||
format = 2
|
||||
pkgname = cpulimit-git
|
||||
pkgbase = cpulimit-git
|
||||
pkgver = 1-1
|
||||
pkgarch = x86_64
|
||||
pkgbuild_sha256sum = b44eb50d49132f14ad7e35865b0478ea7f0b8b9e623e54dd829ef84b4f7848e4
|
||||
packager = Unknown Packager
|
||||
builddate = 1672505075
|
||||
builddir = /home/nartes/Documents/current/freelance-project-34-marketing-blog/deps/cpulimit-fork/pacman-package
|
||||
startdir = /home/nartes/Documents/current/freelance-project-34-marketing-blog/deps/cpulimit-fork/pacman-package
|
||||
buildtool = makepkg
|
||||
buildtoolver = 6.0.2
|
||||
buildenv = !distcc
|
||||
buildenv = color
|
||||
buildenv = !ccache
|
||||
buildenv = check
|
||||
buildenv = !sign
|
||||
options = strip
|
||||
options = docs
|
||||
options = !libtool
|
||||
options = !staticlibs
|
||||
options = emptydirs
|
||||
options = zipman
|
||||
options = purge
|
||||
options = !debug
|
||||
options = !lto
|
||||
installed = a52dec-0.7.4-12-x86_64
|
||||
installed = abseil-cpp-20220623.1-1-x86_64
|
||||
installed = accountsservice-22.08.8-2-x86_64
|
||||
installed = acl-2.3.1-2-x86_64
|
||||
installed = adobe-source-code-pro-fonts-2.038ro+1.058it+1.018var-1-any
|
||||
installed = adwaita-cursors-43-2-any
|
||||
installed = adwaita-icon-theme-43-2-any
|
||||
installed = alsa-lib-1.2.8-1-x86_64
|
||||
installed = alsa-plugins-1:1.2.7.1-1-x86_64
|
||||
installed = alsa-topology-conf-1.2.5.1-1-any
|
||||
installed = alsa-ucm-conf-1.2.8-1-any
|
||||
installed = aom-3.5.0-1-x86_64
|
||||
installed = archlinux-keyring-20221220-1-any
|
||||
installed = argon2-20190702-4-x86_64
|
||||
installed = at-spi2-core-2.46.0-2-x86_64
|
||||
installed = atkmm-2.28.3-1-x86_64
|
||||
installed = attr-2.5.1-2-x86_64
|
||||
installed = audit-3.0.8-1-x86_64
|
||||
installed = autoconf-2.71-1-any
|
||||
installed = automake-1.16.5-1-any
|
||||
installed = avahi-0.8+22+gfd482a7-3-x86_64
|
||||
installed = base-3-1-any
|
||||
installed = bash-5.1.016-1-x86_64
|
||||
installed = bemenu-0.6.13-1-x86_64
|
||||
installed = bemenu-wayland-0.6.13-1-x86_64
|
||||
installed = binutils-2.39-4-x86_64
|
||||
installed = bison-3.8.2-4-x86_64
|
||||
installed = bluez-5.66-1-x86_64
|
||||
installed = bluez-libs-5.66-1-x86_64
|
||||
installed = bluez-utils-5.66-1-x86_64
|
||||
installed = bolt-0.9.4-1-x86_64
|
||||
installed = broadcom-wl-6.30.223.271-436-x86_64
|
||||
installed = brotli-1.0.9-9-x86_64
|
||||
installed = btrfs-progs-6.1-1-x86_64
|
||||
installed = bubblewrap-0.7.0-1-x86_64
|
||||
installed = bzip2-1.0.8-5-x86_64
|
||||
installed = ca-certificates-20220905-1-any
|
||||
installed = ca-certificates-mozilla-3.86-1-x86_64
|
||||
installed = ca-certificates-utils-20220905-1-any
|
||||
installed = cairo-1.17.6-2-x86_64
|
||||
installed = cairomm-1.14.4-1-x86_64
|
||||
installed = cantarell-fonts-1:0.303.1-1-any
|
||||
installed = cifs-utils-7.0-2-x86_64
|
||||
installed = cmake-3.25.1-1-x86_64
|
||||
installed = colord-1.4.6-1-x86_64
|
||||
installed = colord-gtk-common-0.3.0-2-x86_64
|
||||
installed = colord-gtk4-0.3.0-2-x86_64
|
||||
installed = coreutils-9.1-3-x86_64
|
||||
installed = cpulimit-git-113.f4d2682-1-x86_64
|
||||
installed = cpupower-6.1-1-x86_64
|
||||
installed = cracklib-2.9.8-1-x86_64
|
||||
installed = cryptsetup-2.6.0-1-x86_64
|
||||
installed = cups-pk-helper-0.2.7-1-x86_64
|
||||
installed = curl-7.87.0-1-x86_64
|
||||
installed = dav1d-1.0.0-1-x86_64
|
||||
installed = db5.3-5.3.28-2-x86_64
|
||||
installed = dbus-1.14.4-1-x86_64
|
||||
installed = dbus-python-1.2.18-3-x86_64
|
||||
installed = dconf-0.40.0-2-x86_64
|
||||
installed = debugedit-5.0-4-x86_64
|
||||
installed = default-cursors-2-1-any
|
||||
installed = desktop-file-utils-0.26-2-x86_64
|
||||
installed = device-mapper-2.03.18-1-x86_64
|
||||
installed = dhcpcd-9.4.1-1-x86_64
|
||||
installed = diffutils-3.8-1-x86_64
|
||||
installed = dmenu-5.2-1-x86_64
|
||||
installed = dmg2img-1.6.7-5-x86_64
|
||||
installed = dmraid-1.0.0.rc16.3-14-x86_64
|
||||
installed = dnssec-anchors-20190629-3-any
|
||||
installed = dosfstools-4.2-2-x86_64
|
||||
installed = double-conversion-3.2.1-1-x86_64
|
||||
installed = duktape-2.7.0-5-x86_64
|
||||
installed = e2fsprogs-1.46.5-4-x86_64
|
||||
installed = efibootmgr-18-1-x86_64
|
||||
installed = efivar-38-2-x86_64
|
||||
installed = egl-wayland-2:1.1.11-2-x86_64
|
||||
installed = eglexternalplatform-1.1-2-any
|
||||
installed = enchant-2.3.3-2-x86_64
|
||||
installed = eog-43.1-1-x86_64
|
||||
installed = exempi-2.6.3-1-x86_64
|
||||
installed = exiv2-0.27.5-3-x86_64
|
||||
installed = expat-2.5.0-1-x86_64
|
||||
installed = faad2-2.10.1-1-x86_64
|
||||
installed = fakeroot-1.30.1-1-x86_64
|
||||
installed = ffmpeg-2:5.1.2-1-x86_64
|
||||
installed = ffmpeg4.4-4.4.2-3-x86_64
|
||||
installed = fftw-3.3.10-3-x86_64
|
||||
installed = file-5.44-1-x86_64
|
||||
installed = filesystem-2022.10.18-1-x86_64
|
||||
installed = findutils-4.9.0-1-x86_64
|
||||
installed = flac-1.4.2-1-x86_64
|
||||
installed = flex-2.6.4-3-x86_64
|
||||
installed = fontconfig-2:2.14.1-2-x86_64
|
||||
installed = freeglut-3.4.0-1-x86_64
|
||||
installed = freetype2-2.12.1-1-x86_64
|
||||
installed = fribidi-1.0.12-1-x86_64
|
||||
installed = fuse-common-3.12.0-1-x86_64
|
||||
installed = fuse3-3.12.0-1-x86_64
|
||||
installed = gawk-5.2.1-1-x86_64
|
||||
installed = gc-8.2.2-1-x86_64
|
||||
installed = gcc-12.2.0-1-x86_64
|
||||
installed = gcc-libs-12.2.0-1-x86_64
|
||||
installed = gcr-3.41.1-3-x86_64
|
||||
installed = gcr-4-4.0.0-1-x86_64
|
||||
installed = gdbm-1.23-1-x86_64
|
||||
installed = gdk-pixbuf2-2.42.10-1-x86_64
|
||||
installed = geoclue-2.6.0-3-x86_64
|
||||
installed = geocode-glib-2-3.26.4-2-x86_64
|
||||
installed = geocode-glib-common-3.26.4-2-x86_64
|
||||
installed = gettext-0.21.1-2-x86_64
|
||||
installed = giflib-5.2.1-2-x86_64
|
||||
installed = git-2.39.0-1-x86_64
|
||||
installed = glib-networking-1:2.74.0-1-x86_64
|
||||
installed = glib2-2.74.4-1-x86_64
|
||||
installed = glibc-2.36-6-x86_64
|
||||
installed = glibmm-2.66.5-1-x86_64
|
||||
installed = glibmm-2.68-2.74.0-1-x86_64
|
||||
installed = glslang-11.11.0-1-x86_64
|
||||
installed = glu-9.0.2-3-x86_64
|
||||
installed = gmp-6.2.1-2-x86_64
|
||||
installed = gnome-autoar-0.4.3-2-x86_64
|
||||
installed = gnome-bluetooth-3.0-42.5-1-x86_64
|
||||
installed = gnome-color-manager-3.36.0+r42+g90481514-1-x86_64
|
||||
installed = gnome-control-center-43.2-1-x86_64
|
||||
installed = gnome-desktop-1:43-1-x86_64
|
||||
installed = gnome-desktop-4-1:43-1-x86_64
|
||||
installed = gnome-desktop-common-1:43-1-x86_64
|
||||
installed = gnome-disk-utility-43.0-1-x86_64
|
||||
installed = gnome-online-accounts-3.46.0-1-x86_64
|
||||
installed = gnome-settings-daemon-43.0-2-x86_64
|
||||
installed = gnome-terminal-3.46.7-1-x86_64
|
||||
installed = gnu-free-fonts-20120503-8-any
|
||||
installed = gnu-netcat-0.7.1-9-x86_64
|
||||
installed = gnupg-2.2.40-1-x86_64
|
||||
installed = gnutls-3.7.8-4-x86_64
|
||||
installed = go-2:1.19.4-1-x86_64
|
||||
installed = gobject-introspection-runtime-1.74.0-1-x86_64
|
||||
installed = google-chrome-108.0.5359.124-1-x86_64
|
||||
installed = gperftools-2.10-1-x86_64
|
||||
installed = gpgme-1.18.0-1-x86_64
|
||||
installed = gpm-1.20.7.r38.ge82d1a6-4-x86_64
|
||||
installed = gptfdisk-1.0.9-2-x86_64
|
||||
installed = graphene-1.10.8-1-x86_64
|
||||
installed = graphite-1:1.3.14-2-x86_64
|
||||
installed = grep-3.8-2-x86_64
|
||||
installed = groff-1.22.4-7-x86_64
|
||||
installed = gsettings-desktop-schemas-43.0-1-any
|
||||
installed = gsm-1.0.22-1-x86_64
|
||||
installed = gsound-1.0.3-2-x86_64
|
||||
installed = gst-plugins-bad-libs-1.20.5-1-x86_64
|
||||
installed = gst-plugins-base-libs-1.20.5-1-x86_64
|
||||
installed = gstreamer-1.20.5-1-x86_64
|
||||
installed = gtk-update-icon-cache-1:4.8.3-1-x86_64
|
||||
installed = gtk3-1:3.24.36-1-x86_64
|
||||
installed = gtk4-1:4.8.3-1-x86_64
|
||||
installed = gtkmm3-3.24.7-1-x86_64
|
||||
installed = guile-3.0.8-3-x86_64
|
||||
installed = gupnp-dlna-0.12.0-2-x86_64
|
||||
installed = gvfs-1.50.2-1-x86_64
|
||||
installed = gzip-1.12-1-x86_64
|
||||
installed = harfbuzz-6.0.0-1-x86_64
|
||||
installed = harfbuzz-icu-6.0.0-1-x86_64
|
||||
installed = hicolor-icon-theme-0.17-2-any
|
||||
installed = hidapi-0.12.0-1-x86_64
|
||||
installed = highway-1.0.2-1-x86_64
|
||||
installed = htop-3.2.1-1-x86_64
|
||||
installed = http-parser-2.9.4-1-x86_64
|
||||
installed = hunspell-1.7.1-1-x86_64
|
||||
installed = hwdata-0.365-1-any
|
||||
installed = hwloc-2.8.0-1-x86_64
|
||||
installed = hyphen-2.8.8-5-x86_64
|
||||
installed = iana-etc-20221215-1-any
|
||||
installed = ibus-1.5.27-1-x86_64
|
||||
installed = icu-72.1-2-x86_64
|
||||
installed = imath-3.1.6-1-x86_64
|
||||
installed = iniparser-4.1-4-x86_64
|
||||
installed = intel-ucode-20221108-1-any
|
||||
installed = iproute2-6.1.0-3-x86_64
|
||||
installed = iptables-1:1.8.8-2-x86_64
|
||||
installed = iputils-20221126-1-x86_64
|
||||
installed = ipython-8.7.0-1-any
|
||||
installed = iso-codes-4.12.0-1-any
|
||||
installed = jack2-1.9.21-3-x86_64
|
||||
installed = jansson-2.14-2-x86_64
|
||||
installed = jasper-4.0.0-1-x86_64
|
||||
installed = jemalloc-1:5.3.0-1-x86_64
|
||||
installed = jq-1.6-4-x86_64
|
||||
installed = json-c-0.16-1-x86_64
|
||||
installed = json-glib-1.6.6-2-x86_64
|
||||
installed = jsoncpp-1.9.5-2-x86_64
|
||||
installed = kbd-2.5.1-1-x86_64
|
||||
installed = keychain-2.8.5-2-any
|
||||
installed = keyutils-1.6.3-1-x86_64
|
||||
installed = kmod-30-3-x86_64
|
||||
installed = krb5-1.20.1-1-x86_64
|
||||
installed = kwayland-5.101.0-1-x86_64
|
||||
installed = l-smash-2.14.5-2-x86_64
|
||||
installed = lame-3.100-4-x86_64
|
||||
installed = lcms2-2.14-1-x86_64
|
||||
installed = ldb-2:2.6.1-1-x86_64
|
||||
installed = ldns-1.8.3-2-x86_64
|
||||
installed = less-1:608-1-x86_64
|
||||
installed = libadwaita-1:1.2.0-1-x86_64
|
||||
installed = libaio-0.3.113-1-x86_64
|
||||
installed = libarchive-3.6.2-2-x86_64
|
||||
installed = libass-0.17.0-1-x86_64
|
||||
installed = libassuan-2.5.5-1-x86_64
|
||||
installed = libasyncns-1:0.8+r3+g68cd5af-2-x86_64
|
||||
installed = libatasmart-0.19-5-x86_64
|
||||
installed = libavc1394-0.5.4-4-x86_64
|
||||
installed = libavif-0.11.1-1-x86_64
|
||||
installed = libb2-0.98.1-2-x86_64
|
||||
installed = libblockdev-2.28-1-x86_64
|
||||
installed = libbluray-1.3.4-1-x86_64
|
||||
installed = libbpf-1.0.1-1-x86_64
|
||||
installed = libbs2b-3.1.0-8-x86_64
|
||||
installed = libbsd-0.11.7-1-x86_64
|
||||
installed = libbytesize-2.7-1-x86_64
|
||||
installed = libcamera-0.0.3-1-x86_64
|
||||
installed = libcanberra-1:0.30+r2+gc0620e4-2-x86_64
|
||||
installed = libcap-2.66-1-x86_64
|
||||
installed = libcap-ng-0.8.3-1-x86_64
|
||||
installed = libcdio-2.1.0-3-x86_64
|
||||
installed = libcdio-paranoia-10.2+2.0.1-2-x86_64
|
||||
installed = libcloudproviders-0.3.1+r8+g3a229ee-1-x86_64
|
||||
installed = libcolord-1.4.6-1-x86_64
|
||||
installed = libcue-2.2.1-2-x86_64
|
||||
installed = libcups-1:2.4.2-3-x86_64
|
||||
installed = libdaemon-0.14-5-x86_64
|
||||
installed = libdatrie-0.2.13-2-x86_64
|
||||
installed = libdca-0.0.7-1-x86_64
|
||||
installed = libde265-1.0.9-1-x86_64
|
||||
installed = libdispatch-5.5.0-1-x86_64
|
||||
installed = libdrm-2.4.114-1-x86_64
|
||||
installed = libdvbpsi-1:1.3.3-2-x86_64
|
||||
installed = libdvdread-6.1.3-1-x86_64
|
||||
installed = libebml-1.4.4-1-x86_64
|
||||
installed = libedit-20210910_3.1-2-x86_64
|
||||
installed = libelf-0.188-1-x86_64
|
||||
installed = libepoxy-1.5.10-1-x86_64
|
||||
installed = libevdev-1.13.0-1-x86_64
|
||||
installed = libevent-2.1.12-4-x86_64
|
||||
installed = libexif-0.6.24-1-x86_64
|
||||
installed = libffi-3.4.4-1-x86_64
|
||||
installed = libfontenc-1.1.7-1-x86_64
|
||||
installed = libgcrypt-1.10.1-2-x86_64
|
||||
installed = libgexiv2-0.14.0-3-x86_64
|
||||
installed = libgit2-1:1.5.0-2-x86_64
|
||||
installed = libglvnd-1.6.0-1-x86_64
|
||||
installed = libgnomekbd-1:3.28.1-1-x86_64
|
||||
installed = libgpg-error-1.46-2-x86_64
|
||||
installed = libgrss-0.7.0+16+g971c421-3-x86_64
|
||||
installed = libgsf-1.14.50-1-x86_64
|
||||
installed = libgtop-2.40.0+2+g31db82ef-2-x86_64
|
||||
installed = libgudev-237-2-x86_64
|
||||
installed = libgusb-0.4.3-1-x86_64
|
||||
installed = libgweather-4-4.2.0-1-x86_64
|
||||
installed = libgxps-0.3.2-2-x86_64
|
||||
installed = libhandy-1.8.0-1-x86_64
|
||||
installed = libheif-1.14.0-1-x86_64
|
||||
installed = libibus-1.5.27-1-x86_64
|
||||
installed = libical-3.0.16-4-x86_64
|
||||
installed = libice-1.1.1-1-x86_64
|
||||
installed = libid3tag-0.15.1b-11-x86_64
|
||||
installed = libidn-1.41-1-x86_64
|
||||
installed = libidn2-2.3.4-3-x86_64
|
||||
installed = libiec61883-1.2.0-7-x86_64
|
||||
installed = libimobiledevice-1.3.0-5-x86_64
|
||||
installed = libinih-56-1-x86_64
|
||||
installed = libinput-1.22.0-1-x86_64
|
||||
installed = libiptcdata-1.0.5-1-x86_64
|
||||
installed = libisl-0.25-1-x86_64
|
||||
installed = libjpeg-turbo-2.1.4-2-x86_64
|
||||
installed = libjxl-0.7.0-3-x86_64
|
||||
installed = libksba-1.6.2-1-x86_64
|
||||
installed = libldap-2.6.3-2-x86_64
|
||||
installed = libmad-0.15.1b-9-x86_64
|
||||
installed = libmalcontent-0.11.0-1-x86_64
|
||||
installed = libmanette-0.2.6-3-x86_64
|
||||
installed = libmatroska-1.7.1-1-x86_64
|
||||
installed = libmd-1.0.4-1-x86_64
|
||||
installed = libmfx-22.4.4-1-x86_64
|
||||
installed = libmm-glib-1.20.2-1-x86_64
|
||||
installed = libmng-2.0.3-3-x86_64
|
||||
installed = libmnl-1.0.5-1-x86_64
|
||||
installed = libmodplug-0.8.9.0-4-x86_64
|
||||
installed = libmpc-1.3.1-1-x86_64
|
||||
installed = libmpcdec-1:0.1+r475-3-x86_64
|
||||
installed = libmpeg2-0.5.1-7-x86_64
|
||||
installed = libnautilus-extension-43.1-1-x86_64
|
||||
installed = libnetfilter_conntrack-1.0.9-1-x86_64
|
||||
installed = libnfnetlink-1.0.2-1-x86_64
|
||||
installed = libnftnl-1.2.4-1-x86_64
|
||||
installed = libnghttp2-1.51.0-1-x86_64
|
||||
installed = libnl-3.7.0-1-x86_64
|
||||
installed = libnm-1.40.8-2-x86_64
|
||||
installed = libnma-common-1.10.4-3-x86_64
|
||||
installed = libnma-gtk4-1.10.4-3-x86_64
|
||||
installed = libnotify-0.8.1-1-x86_64
|
||||
installed = libnsl-2.0.0-2-x86_64
|
||||
installed = libogg-1.3.5-1-x86_64
|
||||
installed = libomxil-bellagio-0.9.3-4-x86_64
|
||||
installed = libosinfo-1.10.0-2-x86_64
|
||||
installed = libp11-kit-0.24.1-1-x86_64
|
||||
installed = libpcap-1.10.1-2-x86_64
|
||||
installed = libpciaccess-0.17-1-x86_64
|
||||
installed = libpeas-1.34.0-1-x86_64
|
||||
installed = libpipeline-1.5.7-1-x86_64
|
||||
installed = libplacebo-4.208.0-1-x86_64
|
||||
installed = libplist-2.2.0-5-x86_64
|
||||
installed = libpng-1.6.39-1-x86_64
|
||||
installed = libportal-0.6-1-x86_64
|
||||
installed = libportal-gtk4-0.6-1-x86_64
|
||||
installed = libproxy-0.4.18-2-x86_64
|
||||
installed = libpsl-0.21.1-3-x86_64
|
||||
installed = libpulse-16.1-3-x86_64
|
||||
installed = libpwquality-1.4.5-1-x86_64
|
||||
installed = libraw1394-2.1.2-3-x86_64
|
||||
installed = librest-0.9.1-2-x86_64
|
||||
installed = librsvg-2:2.55.1-1-x86_64
|
||||
installed = libsamplerate-0.2.2-1-x86_64
|
||||
installed = libsasl-2.1.28-3-x86_64
|
||||
installed = libseccomp-2.5.4-1-x86_64
|
||||
installed = libsecret-0.20.5-2-x86_64
|
||||
installed = libsigc++-2.12.0-1-x86_64
|
||||
installed = libsigc++-3.0-3.4.0-1-x86_64
|
||||
installed = libsm-1.2.4-1-x86_64
|
||||
installed = libsndfile-1.1.0-3-x86_64
|
||||
installed = libsoup-2.74.3-1-x86_64
|
||||
installed = libsoup3-3.2.2-1-x86_64
|
||||
installed = libsoxr-0.1.3-3-x86_64
|
||||
installed = libssh-0.10.4-3-x86_64
|
||||
installed = libssh2-1.10.0-3-x86_64
|
||||
installed = libstemmer-2.2.0-2-x86_64
|
||||
installed = libsysprof-capture-3.46.0-1-x86_64
|
||||
installed = libtar-1.2.20-6-x86_64
|
||||
installed = libtasn1-4.19.0-1-x86_64
|
||||
installed = libthai-0.1.29-2-x86_64
|
||||
installed = libtheora-1.1.1-5-x86_64
|
||||
installed = libtiff-4.4.0-4-x86_64
|
||||
installed = libtirpc-1.3.3-2-x86_64
|
||||
installed = libtool-2.4.7-5-x86_64
|
||||
installed = libunistring-1.1-2-x86_64
|
||||
installed = libunwind-1.6.2-2-x86_64
|
||||
installed = libupnp-1.14.15-1-x86_64
|
||||
installed = liburcu-0.13.2-1-x86_64
|
||||
installed = libusb-1.0.26-1-x86_64
|
||||
installed = libusbmuxd-2.0.2-1-x86_64
|
||||
installed = libutempter-1.2.1-3-x86_64
|
||||
installed = libuv-1.44.2-1-x86_64
|
||||
installed = libva-2.16.0-1-x86_64
|
||||
installed = libvdpau-1.5-1-x86_64
|
||||
installed = libverto-0.3.2-4-x86_64
|
||||
installed = libvorbis-1.3.7-3-x86_64
|
||||
installed = libvpx-1.12.0-2-x86_64
|
||||
installed = libwacom-2.5.0-1-x86_64
|
||||
installed = libwbclient-4.17.4-2-x86_64
|
||||
installed = libwebp-1.2.4-1-x86_64
|
||||
installed = libwpe-1.14.0-1-x86_64
|
||||
installed = libx11-1.8.3-3-x86_64
|
||||
installed = libxau-1.0.11-1-x86_64
|
||||
installed = libxcb-1.15-2-x86_64
|
||||
installed = libxcomposite-0.4.6-1-x86_64
|
||||
installed = libxcrypt-4.4.33-1-x86_64
|
||||
installed = libxcursor-1.2.1-3-x86_64
|
||||
installed = libxcvt-0.1.2-1-x86_64
|
||||
installed = libxdamage-1.1.6-1-x86_64
|
||||
installed = libxdmcp-1.1.4-1-x86_64
|
||||
installed = libxext-1.3.5-1-x86_64
|
||||
installed = libxfixes-6.0.0-2-x86_64
|
||||
installed = libxfont2-2.0.6-1-x86_64
|
||||
installed = libxft-2.3.7-1-x86_64
|
||||
installed = libxi-1.8-2-x86_64
|
||||
installed = libxinerama-1.1.5-1-x86_64
|
||||
installed = libxkbcommon-1.4.1-2-x86_64
|
||||
installed = libxkbcommon-x11-1.4.1-2-x86_64
|
||||
installed = libxkbfile-1.1.2-1-x86_64
|
||||
installed = libxklavier-5.4-3-x86_64
|
||||
installed = libxml2-2.10.3-2-x86_64
|
||||
installed = libxmu-1.1.4-1-x86_64
|
||||
installed = libxpm-3.5.14-1-x86_64
|
||||
installed = libxrandr-1.5.3-1-x86_64
|
||||
installed = libxrender-0.9.11-1-x86_64
|
||||
installed = libxshmfence-1.3.2-1-x86_64
|
||||
installed = libxslt-1.1.37-2-x86_64
|
||||
installed = libxss-1.2.3-4-x86_64
|
||||
installed = libxt-1.2.1-1-x86_64
|
||||
installed = libxtst-1.2.4-1-x86_64
|
||||
installed = libxv-1.0.12-1-x86_64
|
||||
installed = libxvmc-1.0.13-1-x86_64
|
||||
installed = libxxf86vm-1.1.5-1-x86_64
|
||||
installed = libyaml-0.2.5-1-x86_64
|
||||
installed = libyuv-r2322+3aebf69d-1-x86_64
|
||||
installed = licenses-20220125-1-any
|
||||
installed = links-2.28-2-x86_64
|
||||
installed = linux-6.1.1.arch1-1-x86_64
|
||||
installed = linux-api-headers-5.18.15-1-any
|
||||
installed = linux-firmware-20221214.f3c283e-1-any
|
||||
installed = linux-firmware-whence-20221214.f3c283e-1-any
|
||||
installed = llvm-libs-14.0.6-4-x86_64
|
||||
installed = lm_sensors-1:3.6.0.r41.g31d1f125-2-x86_64
|
||||
installed = lmdb-0.9.29-1-x86_64
|
||||
installed = lua52-5.2.4-5-x86_64
|
||||
installed = lua53-5.3.6-1-x86_64
|
||||
installed = lvm2-2.03.18-1-x86_64
|
||||
installed = lz4-1:1.9.4-1-x86_64
|
||||
installed = lzo-2.10-4-x86_64
|
||||
installed = m4-1.4.19-1-x86_64
|
||||
installed = make-4.3-5-x86_64
|
||||
installed = man-db-2.11.1-1-x86_64
|
||||
installed = man-pages-6.01-1-any
|
||||
installed = mc-4.8.28-2-x86_64
|
||||
installed = md4c-0.4.8-1-x86_64
|
||||
installed = mdadm-4.2-2-x86_64
|
||||
installed = mesa-22.3.1-1-x86_64
|
||||
installed = minizip-1:1.2.13-2-x86_64
|
||||
installed = mkinitcpio-34-2-any
|
||||
installed = mkinitcpio-busybox-1.35.0-1-x86_64
|
||||
installed = mobile-broadband-provider-info-20221107-1-any
|
||||
installed = moc-1:2.5.2-8-x86_64
|
||||
installed = mpfr-4.1.1.p1-1-x86_64
|
||||
installed = mtdev-1.1.6-2-x86_64
|
||||
installed = nautilus-43.1-1-x86_64
|
||||
installed = ncurses-6.3-3-x86_64
|
||||
installed = ndctl-74-1-x86_64
|
||||
installed = netctl-1.28-1-any
|
||||
installed = nettle-3.8.1-1-x86_64
|
||||
installed = nmap-7.93-1-x86_64
|
||||
installed = npth-1.6-3-x86_64
|
||||
installed = nspr-4.35-1-x86_64
|
||||
installed = nss-3.86-1-x86_64
|
||||
installed = ocl-icd-2.3.1-1-x86_64
|
||||
installed = oniguruma-6.9.8-1-x86_64
|
||||
installed = openal-1.22.2-1-x86_64
|
||||
installed = opencore-amr-0.1.6-1-x86_64
|
||||
installed = openexr-3.1.5-1-x86_64
|
||||
installed = openjpeg2-2.5.0-1-x86_64
|
||||
installed = openmpi-4.1.4-4-x86_64
|
||||
installed = openpmix-4.2.2-1-x86_64
|
||||
installed = openresolv-3.12.0-1-any
|
||||
installed = openssh-9.1p1-3-x86_64
|
||||
installed = openssl-3.0.7-4-x86_64
|
||||
installed = openssl-1.1-1.1.1.s-4-x86_64
|
||||
installed = opus-1.3.1-3-x86_64
|
||||
installed = orc-0.4.33-1-x86_64
|
||||
installed = osinfo-db-20221130-1-any
|
||||
installed = p11-kit-0.24.1-1-x86_64
|
||||
installed = pacman-6.0.2-5-x86_64
|
||||
installed = pacman-mirrorlist-20221204-1-any
|
||||
installed = pam-1.5.2-1-x86_64
|
||||
installed = pambase-20221020-1-any
|
||||
installed = pango-1:1.50.12-1-x86_64
|
||||
installed = pangomm-2.46.3-1-x86_64
|
||||
installed = parted-3.5-1-x86_64
|
||||
installed = patch-2.7.6-8-x86_64
|
||||
installed = pavucontrol-1:5.0+r61+gee77d86-2-x86_64
|
||||
installed = pciutils-3.9.0-2-x86_64
|
||||
installed = pcre-8.45-3-x86_64
|
||||
installed = pcre2-10.40-3-x86_64
|
||||
installed = pcsclite-1.9.9-2-x86_64
|
||||
installed = perl-5.36.0-3-x86_64
|
||||
installed = perl-error-0.17029-4-any
|
||||
installed = perl-mailtools-2.21-6-any
|
||||
installed = perl-timedate-2.33-4-any
|
||||
installed = pinentry-1.2.1-1-x86_64
|
||||
installed = pipewire-1:0.3.63-3-x86_64
|
||||
installed = pixman-0.42.2-1-x86_64
|
||||
installed = pkgconf-1.8.0-1-x86_64
|
||||
installed = polkit-122-1-x86_64
|
||||
installed = poppler-22.12.0-1-x86_64
|
||||
installed = poppler-glib-22.12.0-1-x86_64
|
||||
installed = popt-1.19-1-x86_64
|
||||
installed = procps-ng-3.3.17-1-x86_64
|
||||
installed = protobuf-21.12-1-x86_64
|
||||
installed = psmisc-23.6-1-x86_64
|
||||
installed = pulseaudio-16.1-3-x86_64
|
||||
installed = pulseaudio-alsa-1:1.2.7.1-1-x86_64
|
||||
installed = pulseaudio-bluetooth-16.1-3-x86_64
|
||||
installed = pulsemixer-1.5.1-3-any
|
||||
installed = python-3.10.9-1-x86_64
|
||||
installed = python-asttokens-2.2.1-1-any
|
||||
installed = python-backcall-0.2.0-7-any
|
||||
installed = python-decorator-5.1.1-2-any
|
||||
installed = python-executing-1.2.0-1-any
|
||||
installed = python-gobject-3.42.2-1-x86_64
|
||||
installed = python-jedi-0.18.2-1-any
|
||||
installed = python-matplotlib-inline-0.1.6-2-any
|
||||
installed = python-parso-1:0.8.3-1-any
|
||||
installed = python-pexpect-4.8.0-6-any
|
||||
installed = python-pickleshare-0.7.5-8-any
|
||||
installed = python-prompt_toolkit-3.0.36-1-any
|
||||
installed = python-ptyprocess-0.7.0-4-any
|
||||
installed = python-pure-eval-0.2.2-2-any
|
||||
installed = python-pygments-2.13.0-1-any
|
||||
installed = python-six-1.16.0-6-any
|
||||
installed = python-stack-data-0.6.2-1-any
|
||||
installed = python-traitlets-5.8.0-1-any
|
||||
installed = python-wcwidth-0.2.5-6-any
|
||||
installed = qt5-base-5.15.7+kde+r177-1-x86_64
|
||||
installed = qt5-declarative-5.15.7+kde+r25-1-x86_64
|
||||
installed = qt5-svg-5.15.7+kde+r9-1-x86_64
|
||||
installed = qt5-translations-5.15.7-1-any
|
||||
installed = qt5-wayland-5.15.7+kde+r58-1-x86_64
|
||||
installed = qt5-x11extras-5.15.7-1-x86_64
|
||||
installed = qt6-5compat-6.4.1-1-x86_64
|
||||
installed = qt6-base-6.4.1-1-x86_64
|
||||
installed = qt6-declarative-6.4.1-1-x86_64
|
||||
installed = qt6-imageformats-6.4.1-2-x86_64
|
||||
installed = qt6-svg-6.4.1-1-x86_64
|
||||
installed = qt6-translations-6.4.1-1-any
|
||||
installed = qt6-wayland-6.4.1-1-x86_64
|
||||
installed = rav1e-0.6.1-1-x86_64
|
||||
installed = readline-8.2.001-1-x86_64
|
||||
installed = rhash-1.4.3-1-x86_64
|
||||
installed = rnnoise-0.4.1-1-x86_64
|
||||
installed = rtkit-0.13-2-x86_64
|
||||
installed = sbc-2.0-1-x86_64
|
||||
installed = sdl2-2.26.1-1-x86_64
|
||||
installed = seatd-0.7.0-2-x86_64
|
||||
installed = sed-4.9-1-x86_64
|
||||
installed = shaderc-2022.1-4-x86_64
|
||||
installed = shadow-4.12.3-2-x86_64
|
||||
installed = shared-mime-info-2.0+155+gf4e7cbc-1-x86_64
|
||||
installed = slang-2.3.3-2-x86_64
|
||||
installed = smbclient-4.17.4-2-x86_64
|
||||
installed = socat-1.7.4.4-1-x86_64
|
||||
installed = sound-theme-freedesktop-0.8-5-any
|
||||
installed = speex-1.2.1-1-x86_64
|
||||
installed = speexdsp-1.2.1-1-x86_64
|
||||
installed = spirv-tools-2022.1-1-x86_64
|
||||
installed = sqlite-3.40.0-2-x86_64
|
||||
installed = srt-1.5.1-3-x86_64
|
||||
installed = sudo-1.9.12.p1-1-x86_64
|
||||
installed = svt-av1-1.4.1-1-x86_64
|
||||
installed = sway-1:1.7-10-x86_64
|
||||
installed = swaybg-1.2.0-1-x86_64
|
||||
installed = swayidle-1.8.0-1-x86_64
|
||||
installed = swayimg-1.9-2-x86_64
|
||||
installed = swaylock-1.7-1-x86_64
|
||||
installed = sysfsutils-2.1.1-1-x86_64
|
||||
installed = systemd-252.4-2-x86_64
|
||||
installed = systemd-libs-252.4-2-x86_64
|
||||
installed = systemd-sysvcompat-252.4-2-x86_64
|
||||
installed = taglib-1.13-1-x86_64
|
||||
installed = talloc-2.3.4-1-x86_64
|
||||
installed = tar-1.34-1-x86_64
|
||||
installed = tdb-1.4.7-1-x86_64
|
||||
installed = telegram-desktop-4.4.1-3-x86_64
|
||||
installed = terminus-font-4.49.1-2-any
|
||||
installed = tevent-1:0.13.0-1-x86_64
|
||||
installed = texinfo-7.0.1-1-x86_64
|
||||
installed = thin-provisioning-tools-0.9.0-1-x86_64
|
||||
installed = tmux-3.3_a-2-x86_64
|
||||
installed = totem-pl-parser-3.26.6-2-x86_64
|
||||
installed = tpm2-tss-3.2.0-3-x86_64
|
||||
installed = tracker3-3.4.2-1-x86_64
|
||||
installed = tracker3-miners-3.4.2-1-x86_64
|
||||
installed = tree-2.1.0-1-x86_64
|
||||
installed = tslib-1.22-1-x86_64
|
||||
installed = ttf-liberation-2.1.5-1-any
|
||||
installed = ttf-opensans-1.101-2-any
|
||||
installed = tzdata-2022g-1-x86_64
|
||||
installed = udisks2-2.9.4-1-x86_64
|
||||
installed = upower-1.90.0-1-x86_64
|
||||
installed = usbmuxd-1.1.1-1-x86_64
|
||||
installed = util-linux-2.38.1-1-x86_64
|
||||
installed = util-linux-libs-2.38.1-1-x86_64
|
||||
installed = v4l-utils-1.22.1-1-x86_64
|
||||
installed = vid.stab-1.1-3-x86_64
|
||||
installed = vim-9.0.1046-1-x86_64
|
||||
installed = vim-runtime-9.0.1046-1-x86_64
|
||||
installed = vlc-3.0.18-4-x86_64
|
||||
installed = vmaf-2.3.1-1-x86_64
|
||||
installed = volume_key-0.3.12-7-x86_64
|
||||
installed = vte-common-0.70.2-1-x86_64
|
||||
installed = vte3-0.70.2-1-x86_64
|
||||
installed = vulkan-headers-1:1.3.235-1-any
|
||||
installed = vulkan-icd-loader-1.3.235-1-x86_64
|
||||
installed = wavpack-5.6.0-1-x86_64
|
||||
installed = wayland-1.21.0-2-x86_64
|
||||
installed = wayland-protocols-1.31-1-any
|
||||
installed = webkit2gtk-4.1-2.38.3-1-x86_64
|
||||
installed = webp-pixbuf-loader-0.0.7-1-x86_64
|
||||
installed = webrtc-audio-processing-0.3.1-3-x86_64
|
||||
installed = weston-11.0.0-1-x86_64
|
||||
installed = which-2.21-5-x86_64
|
||||
installed = wl-clipboard-1:2.1.0-2-x86_64
|
||||
installed = wlroots-0.15.1-6-x86_64
|
||||
installed = woff2-1.0.2-4-x86_64
|
||||
installed = wpa_supplicant-2:2.10-8-x86_64
|
||||
installed = wpebackend-fdo-1.14.0-1-x86_64
|
||||
installed = x264-3:0.164.r3095.baee400-4-x86_64
|
||||
installed = x265-3.5-3-x86_64
|
||||
installed = xcb-proto-1.15.2-2-any
|
||||
installed = xcb-util-0.4.1-1-x86_64
|
||||
installed = xcb-util-cursor-0.1.4-1-x86_64
|
||||
installed = xcb-util-errors-1.0.1-1-x86_64
|
||||
installed = xcb-util-image-0.4.1-2-x86_64
|
||||
installed = xcb-util-keysyms-0.4.1-4-x86_64
|
||||
installed = xcb-util-renderutil-0.3.10-1-x86_64
|
||||
installed = xcb-util-wm-0.4.2-1-x86_64
|
||||
installed = xdg-dbus-proxy-0.1.4-1-x86_64
|
||||
installed = xdg-utils-1.1.3+25+g8ae0263-1-any
|
||||
installed = xf86-input-libinput-1.2.1-1-x86_64
|
||||
installed = xf86-video-intel-1:2.99.917+916+g31486f40-2-x86_64
|
||||
installed = xfsprogs-6.0.0-2-x86_64
|
||||
installed = xkeyboard-config-2.37-1-any
|
||||
installed = xorg-fonts-encodings-1.0.6-1-any
|
||||
installed = xorg-server-21.1.6-1-x86_64
|
||||
installed = xorg-server-common-21.1.6-1-x86_64
|
||||
installed = xorg-setxkbmap-1.3.3-1-x86_64
|
||||
installed = xorg-xauth-1.1.2-1-x86_64
|
||||
installed = xorg-xinit-1.4.2-1-x86_64
|
||||
installed = xorg-xkbcomp-1.4.6-1-x86_64
|
||||
installed = xorg-xmodmap-1.0.11-1-x86_64
|
||||
installed = xorg-xprop-1.2.6-1-x86_64
|
||||
installed = xorg-xrandr-1.5.2-1-x86_64
|
||||
installed = xorg-xrdb-1.2.1-1-x86_64
|
||||
installed = xorg-xset-1.2.5-1-x86_64
|
||||
installed = xorgproto-2022.2-1-any
|
||||
installed = xvidcore-1.3.7-2-x86_64
|
||||
installed = xxhash-0.8.1-3-x86_64
|
||||
installed = xz-5.4.0-1-x86_64
|
||||
installed = yay-11.3.1-1-x86_64
|
||||
installed = zimg-3.0.4-1-x86_64
|
||||
installed = zlib-1:1.2.13-2-x86_64
|
||||
installed = zsh-5.9-2-x86_64
|
||||
installed = zstd-1.5.2-7-x86_64
|
BIN
deps/cpulimit-fork/pacman-package/pkg/cpulimit-git/.MTREE
vendored
Normal file
BIN
deps/cpulimit-fork/pacman-package/pkg/cpulimit-git/.MTREE
vendored
Normal file
Binary file not shown.
16
deps/cpulimit-fork/pacman-package/pkg/cpulimit-git/.PKGINFO
vendored
Normal file
16
deps/cpulimit-fork/pacman-package/pkg/cpulimit-git/.PKGINFO
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
# Generated by makepkg 6.0.2
|
||||
# using fakeroot version 1.30.1
|
||||
pkgname = cpulimit-git
|
||||
pkgbase = cpulimit-git
|
||||
pkgver = 1-1
|
||||
pkgdesc = Limit cpu usage in %. Actualy sends SIGSTOP/SIGCONT
|
||||
url = https://github.com/opsengine/cpulimit
|
||||
builddate = 1672505075
|
||||
packager = Unknown Packager
|
||||
size = 30920
|
||||
arch = x86_64
|
||||
license = GPL
|
||||
conflict = cpulimit
|
||||
provides = cpulimit
|
||||
depend = glibc
|
||||
makedepend = git
|
BIN
deps/cpulimit-fork/pacman-package/pkg/cpulimit-git/usr/bin/cpulimit
vendored
Executable file
BIN
deps/cpulimit-fork/pacman-package/pkg/cpulimit-git/usr/bin/cpulimit
vendored
Executable file
Binary file not shown.
1
deps/cpulimit-fork/pacman-package/src/cpulimit-git
vendored
Symbolic link
1
deps/cpulimit-fork/pacman-package/src/cpulimit-git
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
/home/nartes/Documents/current/freelance-project-34-marketing-blog/deps/cpulimit-fork/pacman-package/src/../..
|
28
deps/cpulimit-fork/src/Makefile
vendored
Normal file
28
deps/cpulimit-fork/src/Makefile
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
CC?=gcc
|
||||
CFLAGS?=-Wall -g -D_GNU_SOURCE
|
||||
TARGETS=cpulimit
|
||||
LIBS=list.o process_iterator.o process_group.o
|
||||
|
||||
UNAME := $(shell uname)
|
||||
|
||||
ifeq ($(UNAME), FreeBSD)
|
||||
LIBS+=-lkvm
|
||||
endif
|
||||
|
||||
all:: $(TARGETS) $(LIBS)
|
||||
|
||||
cpulimit: cpulimit.c $(LIBS)
|
||||
$(CC) -o cpulimit cpulimit.c $(LIBS) $(CFLAGS)
|
||||
|
||||
process_iterator.o: process_iterator.c process_iterator.h
|
||||
$(CC) -c process_iterator.c $(CFLAGS)
|
||||
|
||||
list.o: list.c list.h
|
||||
$(CC) -c list.c $(CFLAGS)
|
||||
|
||||
process_group.o: process_group.c process_group.h process_iterator.o list.o
|
||||
$(CC) -c process_group.c $(CFLAGS)
|
||||
|
||||
clean:
|
||||
rm -f *~ *.o $(TARGETS)
|
||||
|
555
deps/cpulimit-fork/src/cpulimit.c
vendored
Normal file
555
deps/cpulimit-fork/src/cpulimit.c
vendored
Normal file
@ -0,0 +1,555 @@
|
||||
/**
|
||||
*
|
||||
* cpulimit - a CPU limiter for Linux
|
||||
*
|
||||
* Copyright (C) 2005-2012, by: Angelo Marletta <angelo dot marletta at gmail dot com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
**************************************************************
|
||||
*
|
||||
* This is a simple program to limit the cpu usage of a process
|
||||
* If you modify this code, send me a copy please
|
||||
*
|
||||
* Get the latest version at: http://github.com/opsengine/cpulimit
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
#include <time.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#ifdef __APPLE__ || __FREEBSD__
|
||||
#include <libgen.h>
|
||||
#endif
|
||||
|
||||
#include "process_group.h"
|
||||
#include "list.h"
|
||||
|
||||
#ifdef HAVE_SYS_SYSINFO_H
|
||||
#include <sys/sysinfo.h>
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include "memrchr.c"
|
||||
#endif
|
||||
|
||||
//some useful macro
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
#endif
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
#endif
|
||||
|
||||
//control time slot in microseconds
|
||||
//each slot is splitted in a working slice and a sleeping slice
|
||||
//TODO: make it adaptive, based on the actual system load
|
||||
#define TIME_SLOT 100000
|
||||
|
||||
#define MAX_PRIORITY -10
|
||||
|
||||
/* GLOBAL VARIABLES */
|
||||
|
||||
//the "family"
|
||||
struct process_group pgroup;
|
||||
//pid of cpulimit
|
||||
pid_t cpulimit_pid;
|
||||
//name of this program (maybe cpulimit...)
|
||||
char *program_name;
|
||||
|
||||
//number of cpu
|
||||
int NCPU;
|
||||
|
||||
/* CONFIGURATION VARIABLES */
|
||||
|
||||
//verbose mode
|
||||
int verbose = 0;
|
||||
//lazy mode (exits if there is no process)
|
||||
int lazy = 0;
|
||||
|
||||
//SIGINT and SIGTERM signal handler
|
||||
static void quit(int sig)
|
||||
{
|
||||
//let all the processes continue if stopped
|
||||
struct list_node *node = NULL;
|
||||
if (pgroup.proclist != NULL)
|
||||
{
|
||||
for (node = pgroup.proclist->first; node != NULL; node = node->next) {
|
||||
struct process *p = (struct process*)(node->data);
|
||||
kill(p->pid, SIGCONT);
|
||||
}
|
||||
close_process_group(&pgroup);
|
||||
}
|
||||
//fix ^C little problem
|
||||
printf("\r");
|
||||
fflush(stdout);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
//return t1-t2 in microseconds (no overflow checks, so better watch out!)
|
||||
static inline unsigned long timediff(const struct timeval *t1,const struct timeval *t2)
|
||||
{
|
||||
return (t1->tv_sec - t2->tv_sec) * 1000000 + (t1->tv_usec - t2->tv_usec);
|
||||
}
|
||||
|
||||
static void print_usage(FILE *stream, int exit_code)
|
||||
{
|
||||
fprintf(stream, "Usage: %s [OPTIONS...] TARGET\n", program_name);
|
||||
fprintf(stream, " OPTIONS\n");
|
||||
fprintf(stream, " -l, --limit=N percentage of cpu allowed from 0 to %d (required)\n", 100*NCPU);
|
||||
fprintf(stream, " -v, --verbose show control statistics\n");
|
||||
fprintf(stream, " -z, --lazy exit if there is no target process, or if it dies\n");
|
||||
fprintf(stream, " -i, --include-children limit also the children processes\n");
|
||||
fprintf(stream, " -h, --help display this help and exit\n");
|
||||
fprintf(stream, " TARGET must be exactly one of these:\n");
|
||||
fprintf(stream, " -p, --pid=N pid of the process (implies -z)\n");
|
||||
fprintf(stream, " -e, --exe=FILE name of the executable program file or path name\n");
|
||||
fprintf(stream, " COMMAND [ARGS] run this command and limit it (implies -z)\n");
|
||||
fprintf(stream, "\nReport bugs to <marlonx80@hotmail.com>.\n");
|
||||
exit(exit_code);
|
||||
}
|
||||
|
||||
static void increase_priority() {
|
||||
//find the best available nice value
|
||||
int old_priority = getpriority(PRIO_PROCESS, 0);
|
||||
int priority = old_priority;
|
||||
while (setpriority(PRIO_PROCESS, 0, priority-1) == 0 && priority>MAX_PRIORITY) {
|
||||
priority--;
|
||||
}
|
||||
if (priority != old_priority) {
|
||||
if (verbose) printf("Priority changed to %d\n", priority);
|
||||
}
|
||||
else {
|
||||
if (verbose) printf("Warning: Cannot change priority. Run as root or renice for best results.\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the number of CPUs */
|
||||
static int get_ncpu() {
|
||||
int ncpu;
|
||||
#ifdef _SC_NPROCESSORS_ONLN
|
||||
ncpu = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
#elif defined __APPLE__
|
||||
int mib[2] = {CTL_HW, HW_NCPU};
|
||||
size_t len = sizeof(ncpu);
|
||||
sysctl(mib, 2, &ncpu, &len, NULL, 0);
|
||||
#elif defined _GNU_SOURCE
|
||||
ncpu = get_nprocs();
|
||||
#else
|
||||
ncpu = -1;
|
||||
#endif
|
||||
return ncpu;
|
||||
}
|
||||
|
||||
int get_pid_max()
|
||||
{
|
||||
#ifdef __linux__
|
||||
//read /proc/sys/kernel/pid_max
|
||||
static char buffer[1024];
|
||||
FILE *fd = fopen("/proc/sys/kernel/pid_max", "r");
|
||||
if (fd==NULL) return -1;
|
||||
if (fgets(buffer, sizeof(buffer), fd)==NULL) {
|
||||
fclose(fd);
|
||||
return -1;
|
||||
}
|
||||
fclose(fd);
|
||||
return atoi(buffer);
|
||||
#elif defined __FreeBSD__
|
||||
return 99998;
|
||||
#elif defined __APPLE__
|
||||
return 99998;
|
||||
#endif
|
||||
}
|
||||
|
||||
void limit_process(pid_t pid, double limit, int include_children)
|
||||
{
|
||||
//slice of the slot in which the process is allowed to run
|
||||
struct timespec twork;
|
||||
//slice of the slot in which the process is stopped
|
||||
struct timespec tsleep;
|
||||
//when the last twork has started
|
||||
struct timeval startwork;
|
||||
//when the last twork has finished
|
||||
struct timeval endwork;
|
||||
//initialization
|
||||
memset(&twork, 0, sizeof(struct timespec));
|
||||
memset(&tsleep, 0, sizeof(struct timespec));
|
||||
memset(&startwork, 0, sizeof(struct timeval));
|
||||
memset(&endwork, 0, sizeof(struct timeval));
|
||||
//last working time in microseconds
|
||||
unsigned long workingtime = 0;
|
||||
//generic list item
|
||||
struct list_node *node;
|
||||
//counter
|
||||
int c = 0;
|
||||
|
||||
//get a better priority
|
||||
increase_priority();
|
||||
|
||||
//build the family
|
||||
init_process_group(&pgroup, pid, include_children);
|
||||
|
||||
#define group_stat() \
|
||||
printf( \
|
||||
"Members in the process group owned by %d: %d\n", \
|
||||
pgroup.target_pid, \
|
||||
pgroup.proclist->count \
|
||||
)
|
||||
|
||||
//if (verbose) group_stat();
|
||||
|
||||
//rate at which we are keeping active the processes (range 0-1)
|
||||
//1 means that the process are using all the twork slice
|
||||
double workingrate = -1;
|
||||
while(1) {
|
||||
#ifdef __linux__
|
||||
if (c % 100 == 0)
|
||||
{
|
||||
update_process_group(&pgroup);
|
||||
}
|
||||
else
|
||||
{
|
||||
update_process_group_fast(&pgroup, c, verbose);
|
||||
}
|
||||
#else
|
||||
update_process_group(&pgroup);
|
||||
#endif
|
||||
if (c % 100 == 0)
|
||||
{
|
||||
if (verbose) {
|
||||
group_stat();
|
||||
}
|
||||
}
|
||||
|
||||
if (pgroup.proclist->count==0) {
|
||||
if (verbose) printf("No more processes.\n");
|
||||
//break;
|
||||
}
|
||||
|
||||
//total cpu actual usage (range 0-1)
|
||||
//1 means that the processes are using 100% cpu
|
||||
double pcpu = -1;
|
||||
|
||||
//estimate how much the controlled processes are using the cpu in the working interval
|
||||
for (node = pgroup.proclist->first; node != NULL; node = node->next) {
|
||||
struct process *proc = (struct process*)(node->data);
|
||||
|
||||
if (proc->cpu_usage < 0) {
|
||||
continue;
|
||||
}
|
||||
if (pcpu < 0) pcpu = 0;
|
||||
pcpu += proc->cpu_usage;
|
||||
}
|
||||
|
||||
//adjust work and sleep time slices
|
||||
if (pcpu < 0) {
|
||||
//it's the 1st cycle, initialize workingrate
|
||||
pcpu = limit;
|
||||
workingrate = limit;
|
||||
twork.tv_nsec = TIME_SLOT * limit * 1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
//adjust workingrate
|
||||
workingrate = MIN(workingrate / pcpu * limit, 1);
|
||||
twork.tv_nsec = TIME_SLOT * 1000 * workingrate;
|
||||
}
|
||||
tsleep.tv_nsec = TIME_SLOT * 1000 - twork.tv_nsec;
|
||||
|
||||
if (verbose) {
|
||||
if (c%200==0)
|
||||
printf("\n%%CPU\twork quantum\tsleep quantum\tactive rate\n");
|
||||
if (c%10==0 && c>0)
|
||||
printf("%0.2lf%%\t%6ld us\t%6ld us\t%0.2lf%%\n", pcpu*100, twork.tv_nsec/1000, tsleep.tv_nsec/1000, workingrate*100);
|
||||
}
|
||||
|
||||
//resume processes
|
||||
node = pgroup.proclist->first;
|
||||
while (node != NULL)
|
||||
{
|
||||
struct list_node *next_node = node->next;
|
||||
struct process *proc = (struct process*)(node->data);
|
||||
if (kill(proc->pid,SIGCONT) != 0) {
|
||||
//process is dead, remove it from family
|
||||
if (verbose) fprintf(stderr, "SIGCONT failed. Process %d dead!\n", proc->pid);
|
||||
//remove process from group
|
||||
delete_node(pgroup.proclist, node);
|
||||
remove_process(&pgroup, proc->pid);
|
||||
}
|
||||
node = next_node;
|
||||
}
|
||||
|
||||
//now processes are free to run (same working slice for all)
|
||||
gettimeofday(&startwork, NULL);
|
||||
nanosleep(&twork, NULL);
|
||||
gettimeofday(&endwork, NULL);
|
||||
workingtime = timediff(&endwork, &startwork);
|
||||
|
||||
long delay = workingtime - twork.tv_nsec/1000;
|
||||
if (c>0 && delay>10000) {
|
||||
//delay is too much! signal to user?
|
||||
//fprintf(stderr, "%d %ld us\n", c, delay);
|
||||
}
|
||||
|
||||
if (tsleep.tv_nsec>0) {
|
||||
//stop processes only if tsleep>0
|
||||
node = pgroup.proclist->first;
|
||||
while (node != NULL)
|
||||
{
|
||||
struct list_node *next_node = node->next;
|
||||
struct process *proc = (struct process*)(node->data);
|
||||
if (kill(proc->pid,SIGSTOP)!=0) {
|
||||
//process is dead, remove it from family
|
||||
if (verbose) fprintf(stderr, "SIGSTOP failed. Process %d dead!\n", proc->pid);
|
||||
//remove process from group
|
||||
delete_node(pgroup.proclist, node);
|
||||
remove_process(&pgroup, proc->pid);
|
||||
}
|
||||
node = next_node;
|
||||
}
|
||||
//now the processes are sleeping
|
||||
nanosleep(&tsleep,NULL);
|
||||
}
|
||||
c++;
|
||||
}
|
||||
close_process_group(&pgroup);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
//argument variables
|
||||
const char *exe = NULL;
|
||||
int perclimit = 0;
|
||||
int exe_ok = 0;
|
||||
int pid_ok = 0;
|
||||
int limit_ok = 0;
|
||||
pid_t pid = 0;
|
||||
int include_children = 0;
|
||||
|
||||
//get program name
|
||||
char *p = (char*)memrchr(argv[0], (unsigned int)'/', strlen(argv[0]));
|
||||
program_name = p==NULL ? argv[0] : (p+1);
|
||||
//get current pid
|
||||
cpulimit_pid = getpid();
|
||||
//get cpu count
|
||||
NCPU = get_ncpu();
|
||||
|
||||
//parse arguments
|
||||
int next_option;
|
||||
int option_index = 0;
|
||||
//A string listing valid short options letters
|
||||
const char* short_options = "+p:e:l:vzih";
|
||||
//An array describing valid long options
|
||||
const struct option long_options[] = {
|
||||
{ "pid", required_argument, NULL, 'p' },
|
||||
{ "exe", required_argument, NULL, 'e' },
|
||||
{ "limit", required_argument, NULL, 'l' },
|
||||
{ "verbose", no_argument, NULL, 'v' },
|
||||
{ "lazy", no_argument, NULL, 'z' },
|
||||
{ "include-children", no_argument, NULL, 'i' },
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
do {
|
||||
next_option = getopt_long(argc, argv, short_options,long_options, &option_index);
|
||||
switch(next_option) {
|
||||
case 'p':
|
||||
pid = atoi(optarg);
|
||||
pid_ok = 1;
|
||||
break;
|
||||
case 'e':
|
||||
exe = optarg;
|
||||
exe_ok = 1;
|
||||
break;
|
||||
case 'l':
|
||||
perclimit = atoi(optarg);
|
||||
limit_ok = 1;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
case 'z':
|
||||
lazy = 1;
|
||||
break;
|
||||
case 'i':
|
||||
include_children = 1;
|
||||
break;
|
||||
case 'h':
|
||||
print_usage(stdout, 1);
|
||||
break;
|
||||
case '?':
|
||||
print_usage(stderr, 1);
|
||||
break;
|
||||
case -1:
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
} while(next_option != -1);
|
||||
|
||||
if (pid_ok && (pid <= 1 || pid >= get_pid_max())) {
|
||||
fprintf(stderr,"Error: Invalid value for argument PID\n");
|
||||
print_usage(stderr, 1);
|
||||
exit(1);
|
||||
}
|
||||
if (pid != 0) {
|
||||
lazy = 1;
|
||||
}
|
||||
|
||||
if (!limit_ok) {
|
||||
fprintf(stderr,"Error: You must specify a cpu limit percentage\n");
|
||||
print_usage(stderr, 1);
|
||||
exit(1);
|
||||
}
|
||||
double limit = perclimit / 100.0;
|
||||
if (limit<0 || limit >NCPU) {
|
||||
fprintf(stderr,"Error: limit must be in the range 0-%d00\n", NCPU);
|
||||
print_usage(stderr, 1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int command_mode = optind < argc;
|
||||
if (exe_ok + pid_ok + command_mode == 0) {
|
||||
fprintf(stderr,"Error: You must specify one target process, either by name, pid, or command line\n");
|
||||
print_usage(stderr, 1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (exe_ok + pid_ok + command_mode > 1) {
|
||||
fprintf(stderr,"Error: You must specify exactly one target process, either by name, pid, or command line\n");
|
||||
print_usage(stderr, 1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
//all arguments are ok!
|
||||
signal(SIGINT, quit);
|
||||
signal(SIGTERM, quit);
|
||||
|
||||
//print the number of available cpu
|
||||
if (verbose) printf("%d cpu detected\n", NCPU);
|
||||
|
||||
if (command_mode) {
|
||||
int i;
|
||||
//executable file
|
||||
const char *cmd = argv[optind];
|
||||
//command line arguments
|
||||
char **cmd_args = (char**)malloc((argc-optind + 1) * sizeof(char*));
|
||||
if (cmd_args==NULL) exit(2);
|
||||
for (i=0; i<argc-optind; i++) {
|
||||
cmd_args[i] = argv[i+optind];
|
||||
}
|
||||
cmd_args[i] = NULL;
|
||||
|
||||
if (verbose) {
|
||||
printf("Running command: '%s", cmd);
|
||||
for (i=1; i<argc-optind; i++) {
|
||||
printf(" %s", cmd_args[i]);
|
||||
}
|
||||
printf("'\n");
|
||||
}
|
||||
|
||||
int child = fork();
|
||||
if (child < 0) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
else if (child == 0) {
|
||||
//target process code
|
||||
int ret = execvp(cmd, cmd_args);
|
||||
//if we are here there was an error, show it
|
||||
perror("Error");
|
||||
exit(ret);
|
||||
}
|
||||
else {
|
||||
//parent code
|
||||
free(cmd_args);
|
||||
int limiter = fork();
|
||||
if (limiter < 0) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
else if (limiter > 0) {
|
||||
//parent
|
||||
int status_process;
|
||||
int status_limiter;
|
||||
waitpid(child, &status_process, 0);
|
||||
waitpid(limiter, &status_limiter, 0);
|
||||
if (WIFEXITED(status_process)) {
|
||||
if (verbose) printf("Process %d terminated with exit status %d\n", child, (int)WEXITSTATUS(status_process));
|
||||
exit(WEXITSTATUS(status_process));
|
||||
}
|
||||
printf("Process %d terminated abnormally\n", child);
|
||||
exit(status_process);
|
||||
}
|
||||
else {
|
||||
//limiter code
|
||||
if (verbose) printf("Limiting process %d\n",child);
|
||||
limit_process(child, limit, include_children);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while(1) {
|
||||
//look for the target process..or wait for it
|
||||
pid_t ret = 0;
|
||||
if (pid_ok) {
|
||||
//search by pid
|
||||
ret = find_process_by_pid(pid);
|
||||
if (ret == 0) {
|
||||
printf("No process found\n");
|
||||
}
|
||||
else if (ret < 0) {
|
||||
printf("Process found but you aren't allowed to control it\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
//search by file or path name
|
||||
ret = find_process_by_name(exe);
|
||||
if (ret == 0) {
|
||||
printf("No process found\n");
|
||||
}
|
||||
else if (ret < 0) {
|
||||
printf("Process found but you aren't allowed to control it\n");
|
||||
}
|
||||
else {
|
||||
pid = ret;
|
||||
}
|
||||
}
|
||||
if (ret > 0) {
|
||||
if (ret == cpulimit_pid) {
|
||||
printf("Target process %d is cpulimit itself! Aborting because it makes no sense\n", ret);
|
||||
exit(1);
|
||||
}
|
||||
printf("Process %d found\n", pid);
|
||||
//control
|
||||
limit_process(pid, limit, include_children);
|
||||
}
|
||||
if (lazy) break;
|
||||
sleep(2);
|
||||
};
|
||||
|
||||
exit(0);
|
||||
}
|
148
deps/cpulimit-fork/src/list.c
vendored
Normal file
148
deps/cpulimit-fork/src/list.c
vendored
Normal file
@ -0,0 +1,148 @@
|
||||
/**
|
||||
*
|
||||
* cpulimit - a CPU limiter for Linux
|
||||
*
|
||||
* Copyright (C) 2005-2012, by: Angelo Marletta <angelo dot marletta at gmail dot com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "list.h"
|
||||
|
||||
#define EMPTYLIST NULL
|
||||
|
||||
void init_list(struct list *l,int keysize) {
|
||||
l->first=l->last=NULL;
|
||||
l->keysize=keysize;
|
||||
l->count=0;
|
||||
}
|
||||
|
||||
struct list_node *add_elem(struct list *l,void *elem) {
|
||||
struct list_node *newnode=(struct list_node*)malloc(sizeof(struct list_node));
|
||||
newnode->data=elem;
|
||||
newnode->previous=l->last;
|
||||
newnode->next=NULL;
|
||||
if (l->count==0) {
|
||||
l->first=l->last=newnode;
|
||||
}
|
||||
else {
|
||||
l->last->next=newnode;
|
||||
l->last=newnode;
|
||||
}
|
||||
l->count++;
|
||||
return newnode;
|
||||
}
|
||||
|
||||
void delete_node(struct list *l,struct list_node *node) {
|
||||
if (l->count==1) {
|
||||
l->first=l->last=NULL;
|
||||
}
|
||||
else if (node==l->first) {
|
||||
node->next->previous=NULL;
|
||||
l->first=node->next;
|
||||
}
|
||||
else if (node==l->last) {
|
||||
node->previous->next=NULL;
|
||||
l->last=node->previous;
|
||||
}
|
||||
else {
|
||||
node->previous->next=node->next;
|
||||
node->next->previous=node->previous;
|
||||
}
|
||||
l->count--;
|
||||
free(node);
|
||||
}
|
||||
|
||||
void destroy_node(struct list *l,struct list_node *node) {
|
||||
free(node->data);
|
||||
node->data=NULL;
|
||||
delete_node(l,node);
|
||||
}
|
||||
|
||||
int is_empty_list(struct list *l) {
|
||||
return (l->count==0?TRUE:FALSE);
|
||||
}
|
||||
|
||||
int get_list_count(struct list *l) {
|
||||
return l->count;
|
||||
}
|
||||
|
||||
void *first_elem(struct list *l) {
|
||||
return l->first->data;
|
||||
}
|
||||
|
||||
struct list_node *first_node(struct list *l) {
|
||||
return l->first;
|
||||
}
|
||||
|
||||
void *last_elem(struct list *l) {
|
||||
return l->last->data;
|
||||
}
|
||||
|
||||
struct list_node *last_node(struct list *l) {
|
||||
return l->last;
|
||||
}
|
||||
|
||||
struct list_node *xlocate_node(struct list *l,void *elem,int offset,int length) {
|
||||
struct list_node *tmp;
|
||||
tmp=l->first;
|
||||
while(tmp!=NULL) {
|
||||
if(!memcmp((char*)tmp->data+offset,elem,length==0?l->keysize:length)) return (tmp);
|
||||
tmp=tmp->next;
|
||||
}
|
||||
return EMPTYLIST;
|
||||
}
|
||||
|
||||
struct list_node *locate_node(struct list *l,void *elem) {
|
||||
return(xlocate_node(l,elem,0,0));
|
||||
}
|
||||
|
||||
void *xlocate_elem(struct list *l,void *elem,int offset,int length) {
|
||||
struct list_node *node=xlocate_node(l,elem,offset,length);
|
||||
return(node==NULL?NULL:node->data);
|
||||
}
|
||||
|
||||
void *locate_elem(struct list *l,void *elem) {
|
||||
return(xlocate_elem(l,elem,0,0));
|
||||
}
|
||||
|
||||
void clear_list(struct list *l) {
|
||||
while(l->first!=EMPTYLIST) {
|
||||
struct list_node *tmp;
|
||||
tmp=l->first;
|
||||
l->first=l->first->next;
|
||||
free(tmp);
|
||||
tmp=NULL;
|
||||
}
|
||||
l->last=EMPTYLIST;
|
||||
l->count=0;
|
||||
}
|
||||
|
||||
void destroy_list(struct list *l) {
|
||||
while(l->first!=EMPTYLIST) {
|
||||
struct list_node *tmp;
|
||||
tmp=l->first;
|
||||
l->first=l->first->next;
|
||||
free(tmp->data);
|
||||
tmp->data=NULL;
|
||||
free(tmp);
|
||||
tmp=NULL;
|
||||
}
|
||||
l->last=EMPTYLIST;
|
||||
l->count=0;
|
||||
}
|
138
deps/cpulimit-fork/src/list.h
vendored
Normal file
138
deps/cpulimit-fork/src/list.h
vendored
Normal file
@ -0,0 +1,138 @@
|
||||
/**
|
||||
*
|
||||
* cpulimit - a CPU limiter for Linux
|
||||
*
|
||||
* Copyright (C) 2005-2012, by: Angelo Marletta <angelo dot marletta at gmail dot com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __LIST__
|
||||
|
||||
#define __LIST__
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
struct list_node {
|
||||
//pointer to the content of the node
|
||||
void *data;
|
||||
//pointer to previous node
|
||||
struct list_node *previous;
|
||||
//pointer to next node
|
||||
struct list_node *next;
|
||||
};
|
||||
|
||||
struct list {
|
||||
//first node
|
||||
struct list_node *first;
|
||||
//last node
|
||||
struct list_node *last;
|
||||
//size of the search key in bytes
|
||||
int keysize;
|
||||
//element count
|
||||
int count;
|
||||
};
|
||||
|
||||
/*
|
||||
* Initialize a list, with a specified key size
|
||||
*/
|
||||
void init_list(struct list *l,int keysize);
|
||||
|
||||
/*
|
||||
* Add a new element at the end of the list
|
||||
* return the pointer to the new node
|
||||
*/
|
||||
struct list_node *add_elem(struct list *l,void *elem);
|
||||
|
||||
/*
|
||||
* Delete a node
|
||||
*/
|
||||
void delete_node(struct list *l,struct list_node *node);
|
||||
|
||||
/*
|
||||
* Delete a node from the list, even the content pointed by it
|
||||
* Use only when the content is a dynamically allocated pointer
|
||||
*/
|
||||
void destroy_node(struct list *l,struct list_node *node);
|
||||
|
||||
/*
|
||||
* Check whether a list is empty or not
|
||||
*/
|
||||
int is_empty_list(struct list *l);
|
||||
|
||||
/*
|
||||
* Return the element count of the list
|
||||
*/
|
||||
int get_list_count(struct list *l);
|
||||
|
||||
/*
|
||||
* Return the first element (content of the node) from the list
|
||||
*/
|
||||
void *first_elem(struct list *l);
|
||||
|
||||
/*
|
||||
* Return the first node from the list
|
||||
*/
|
||||
struct list_node *first_node(struct list *l);
|
||||
|
||||
/*
|
||||
* Return the last element (content of the node) from the list
|
||||
*/
|
||||
void *last_elem(struct list *l);
|
||||
|
||||
/*
|
||||
* Return the last node from the list
|
||||
*/
|
||||
struct list_node *last_node(struct list *l);
|
||||
|
||||
/*
|
||||
* Search an element of the list by content
|
||||
* the comparison is done from the specified offset and for a specified length
|
||||
* if offset=0, the comparison starts from the address pointed by data
|
||||
* if length=0, default keysize is used for length
|
||||
* if the element is found, return the node address
|
||||
* else return NULL
|
||||
*/
|
||||
struct list_node *xlocate_node(struct list *l,void *elem,int offset,int length);
|
||||
|
||||
/*
|
||||
* The same of xlocate_node(), but return the content of the node
|
||||
*/
|
||||
void *xlocate_elem(struct list *l,void *elem,int offset,int length);
|
||||
|
||||
/*
|
||||
* The same of calling xlocate_node() with offset=0 and length=0
|
||||
*/
|
||||
struct list_node *locate_node(struct list *l,void *elem);
|
||||
|
||||
/*
|
||||
* The same of locate_node, but return the content of the node
|
||||
*/
|
||||
void *locate_elem(struct list *l,void *elem);
|
||||
|
||||
/*
|
||||
* Delete all the elements in the list
|
||||
*/
|
||||
void clear_list(struct list *l);
|
||||
|
||||
/*
|
||||
* Delete every element in the list, and free the memory pointed by all the node data
|
||||
*/
|
||||
void destroy_list(struct list *l);
|
||||
|
||||
#endif
|
38
deps/cpulimit-fork/src/memrchr.c
vendored
Normal file
38
deps/cpulimit-fork/src/memrchr.c
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2007 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/*
|
||||
* Reverse memchr()
|
||||
* Find the last occurrence of 'c' in the buffer 's' of size 'n'.
|
||||
*/
|
||||
void *
|
||||
memrchr(s, c, n)
|
||||
const void *s;
|
||||
int c;
|
||||
size_t n;
|
||||
{
|
||||
if (n != 0) {
|
||||
const unsigned char *cp;
|
||||
cp = (unsigned char *)s + n;
|
||||
do {
|
||||
if (*(--cp) == (unsigned char)c)
|
||||
return((void *)cp);
|
||||
} while (--n != 0);
|
||||
}
|
||||
return((void *)0);
|
||||
}
|
251
deps/cpulimit-fork/src/process_group.c
vendored
Normal file
251
deps/cpulimit-fork/src/process_group.c
vendored
Normal file
@ -0,0 +1,251 @@
|
||||
/**
|
||||
*
|
||||
* cpulimit - a CPU limiter for Linux
|
||||
*
|
||||
* Copyright (C) 2005-2012, by: Angelo Marletta <angelo dot marletta at gmail dot com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "process_iterator.h"
|
||||
#include "process_group.h"
|
||||
#include "list.h"
|
||||
|
||||
// look for a process by pid
|
||||
// search_pid : pid of the wanted process
|
||||
// return: pid of the found process, if successful
|
||||
// negative pid, if the process does not exist or if the signal fails
|
||||
int find_process_by_pid(pid_t pid)
|
||||
{
|
||||
return (kill(pid,0)==0) ? pid : -pid;
|
||||
}
|
||||
|
||||
// look for a process with a given name
|
||||
// process: the name of the wanted process. it can be an absolute path name to the executable file
|
||||
// or just the file name
|
||||
// return: pid of the found process, if it is found
|
||||
// 0, if it's not found
|
||||
// negative pid, if it is found but it's not possible to control it
|
||||
int find_process_by_name(const char *process_name)
|
||||
{
|
||||
//pid of the target process
|
||||
pid_t pid = -1;
|
||||
|
||||
//process iterator
|
||||
struct process_iterator it;
|
||||
struct process proc;
|
||||
struct process_filter filter;
|
||||
filter.pid = 0;
|
||||
filter.include_children = 0;
|
||||
init_process_iterator(&it, &filter);
|
||||
while (get_next_process(&it, &proc) != -1)
|
||||
{
|
||||
//process found
|
||||
if (strncmp(basename(proc.command), process_name, strlen(process_name))==0 && kill(pid,SIGCONT)==0) {
|
||||
//process is ok!
|
||||
pid = proc.pid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (close_process_iterator(&it) != 0) exit(1);
|
||||
if (pid >= 0) {
|
||||
//ok, the process was found
|
||||
return pid;
|
||||
}
|
||||
else {
|
||||
//process not found
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int init_process_group(struct process_group *pgroup, int target_pid, int include_children)
|
||||
{
|
||||
//hashtable initialization
|
||||
memset(&pgroup->proctable, 0, sizeof(pgroup->proctable));
|
||||
pgroup->target_pid = target_pid;
|
||||
pgroup->include_children = include_children;
|
||||
pgroup->proclist = (struct list*)malloc(sizeof(struct list));
|
||||
init_list(pgroup->proclist, 4);
|
||||
memset(&pgroup->last_update, 0, sizeof(pgroup->last_update));
|
||||
update_process_group(pgroup);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int close_process_group(struct process_group *pgroup)
|
||||
{
|
||||
int i;
|
||||
int size = sizeof(pgroup->proctable) / sizeof(struct process*);
|
||||
for (i=0; i<size; i++) {
|
||||
if (pgroup->proctable[i] != NULL) {
|
||||
//free() history for each process
|
||||
destroy_list(pgroup->proctable[i]);
|
||||
free(pgroup->proctable[i]);
|
||||
pgroup->proctable[i] = NULL;
|
||||
}
|
||||
}
|
||||
clear_list(pgroup->proclist);
|
||||
free(pgroup->proclist);
|
||||
pgroup->proclist = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void remove_terminated_processes(struct process_group *pgroup)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
//return t1-t2 in microseconds (no overflow checks, so better watch out!)
|
||||
static inline unsigned long timediff(const struct timeval *t1,const struct timeval *t2)
|
||||
{
|
||||
return (t1->tv_sec - t2->tv_sec) * 1000000 + (t1->tv_usec - t2->tv_usec);
|
||||
}
|
||||
|
||||
//parameter in range 0-1
|
||||
#define ALFA 0.08
|
||||
#define MIN_DT 20
|
||||
|
||||
void update_process_group_fast(struct process_group *pgroup, int cycle, int verbose)
|
||||
{
|
||||
struct list_node *node;
|
||||
struct process tmp_process;
|
||||
struct timeval now;
|
||||
long dt;
|
||||
double sample;
|
||||
|
||||
gettimeofday(&now, NULL);
|
||||
//time elapsed from previous sample (in ms)
|
||||
dt = timediff(&now, &pgroup->last_update) / 1000;
|
||||
|
||||
//estimate how much the controlled processes are using the cpu in the working interval
|
||||
for (node = pgroup->proclist->first; node != NULL; node = node->next) {
|
||||
struct process *proc = (struct process*)(node->data);
|
||||
|
||||
if (read_process_info(proc->pid, &tmp_process) != 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
sample = 1.0 * (tmp_process.cputime - proc->cputime) / dt;
|
||||
if (proc->cpu_usage == -1) {
|
||||
//initialization
|
||||
proc->cpu_usage = sample;
|
||||
}
|
||||
else {
|
||||
//usage adjustment
|
||||
proc->cpu_usage = (1.0-ALFA) * proc->cpu_usage + ALFA * sample;
|
||||
}
|
||||
proc->cputime = tmp_process.cputime;
|
||||
|
||||
if (verbose && cycle % 10 == 0)
|
||||
{
|
||||
printf(
|
||||
"%d %5.2lf, ",
|
||||
proc->pid,
|
||||
proc->cpu_usage * 100
|
||||
);
|
||||
}
|
||||
proc->cputime = tmp_process.cputime;
|
||||
}
|
||||
pgroup->last_update = now;
|
||||
}
|
||||
|
||||
void update_process_group(struct process_group *pgroup)
|
||||
{
|
||||
struct process_iterator it;
|
||||
struct process tmp_process;
|
||||
struct process_filter filter;
|
||||
struct timeval now;
|
||||
gettimeofday(&now, NULL);
|
||||
//time elapsed from previous sample (in ms)
|
||||
long dt = timediff(&now, &pgroup->last_update) / 1000;
|
||||
filter.pid = pgroup->target_pid;
|
||||
filter.include_children = pgroup->include_children;
|
||||
init_process_iterator(&it, &filter);
|
||||
clear_list(pgroup->proclist);
|
||||
init_list(pgroup->proclist, 4);
|
||||
|
||||
while (get_next_process(&it, &tmp_process) != -1)
|
||||
{
|
||||
// struct timeval t;
|
||||
// gettimeofday(&t, NULL);
|
||||
// printf("T=%ld.%ld PID=%d PPID=%d START=%d CPUTIME=%d\n", t.tv_sec, t.tv_usec, tmp_process.pid, tmp_process.ppid, tmp_process.starttime, tmp_process.cputime);
|
||||
int hashkey = pid_hashfn(tmp_process.pid);
|
||||
if (pgroup->proctable[hashkey] == NULL)
|
||||
{
|
||||
//empty bucket
|
||||
pgroup->proctable[hashkey] = malloc(sizeof(struct list));
|
||||
struct process *new_process = malloc(sizeof(struct process));
|
||||
tmp_process.cpu_usage = -1;
|
||||
memcpy(new_process, &tmp_process, sizeof(struct process));
|
||||
init_list(pgroup->proctable[hashkey], 4);
|
||||
add_elem(pgroup->proctable[hashkey], new_process);
|
||||
add_elem(pgroup->proclist, new_process);
|
||||
}
|
||||
else
|
||||
{
|
||||
//existing bucket
|
||||
struct process *p = (struct process*)locate_elem(pgroup->proctable[hashkey], &tmp_process);
|
||||
if (p == NULL)
|
||||
{
|
||||
//process is new. add it
|
||||
struct process *new_process = malloc(sizeof(struct process));
|
||||
tmp_process.cpu_usage = -1;
|
||||
memcpy(new_process, &tmp_process, sizeof(struct process));
|
||||
add_elem(pgroup->proctable[hashkey], new_process);
|
||||
add_elem(pgroup->proclist, new_process);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(tmp_process.pid == p->pid);
|
||||
assert(tmp_process.starttime == p->starttime);
|
||||
add_elem(pgroup->proclist, p);
|
||||
if (dt < MIN_DT) continue;
|
||||
//process exists. update CPU usage
|
||||
double sample = 1.0 * (tmp_process.cputime - p->cputime) / dt;
|
||||
if (p->cpu_usage == -1) {
|
||||
//initialization
|
||||
p->cpu_usage = sample;
|
||||
}
|
||||
else {
|
||||
//usage adjustment
|
||||
p->cpu_usage = (1.0-ALFA) * p->cpu_usage + ALFA * sample;
|
||||
}
|
||||
p->cputime = tmp_process.cputime;
|
||||
}
|
||||
}
|
||||
}
|
||||
close_process_iterator(&it);
|
||||
if (dt < MIN_DT) return;
|
||||
pgroup->last_update = now;
|
||||
}
|
||||
|
||||
int remove_process(struct process_group *pgroup, int pid)
|
||||
{
|
||||
int hashkey = pid_hashfn(pid);
|
||||
if (pgroup->proctable[hashkey] == NULL) return 1; //nothing to delete
|
||||
struct list_node *node = (struct list_node*)locate_node(pgroup->proctable[hashkey], &pid);
|
||||
if (node == NULL) return 2;
|
||||
delete_node(pgroup->proctable[hashkey], node);
|
||||
return 0;
|
||||
}
|
59
deps/cpulimit-fork/src/process_group.h
vendored
Normal file
59
deps/cpulimit-fork/src/process_group.h
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
/**
|
||||
*
|
||||
* cpulimit - a CPU limiter for Linux
|
||||
*
|
||||
* Copyright (C) 2005-2012, by: Angelo Marletta <angelo dot marletta at gmail dot com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __PROCESS_GROUP_H
|
||||
|
||||
#define __PROCESS_GROUP_H
|
||||
|
||||
#include "process_iterator.h"
|
||||
|
||||
#include "list.h"
|
||||
|
||||
#define PIDHASH_SZ 1024
|
||||
#define pid_hashfn(x) ((((x) >> 8) ^ (x)) & (PIDHASH_SZ - 1))
|
||||
|
||||
struct process_group
|
||||
{
|
||||
//hashtable with all the processes (array of struct list of struct process)
|
||||
struct list *proctable[PIDHASH_SZ];
|
||||
struct list *proclist;
|
||||
pid_t target_pid;
|
||||
int include_children;
|
||||
struct timeval last_update;
|
||||
};
|
||||
|
||||
#ifdef __linux__
|
||||
void update_process_group_fast(struct process_group *pgroup, int cycle, int verbose);
|
||||
#endif
|
||||
|
||||
int init_process_group(struct process_group *pgroup, int target_pid, int include_children);
|
||||
|
||||
void update_process_group(struct process_group *pgroup);
|
||||
|
||||
int close_process_group(struct process_group *pgroup);
|
||||
|
||||
int find_process_by_pid(pid_t pid);
|
||||
|
||||
int find_process_by_name(const char *process_name);
|
||||
|
||||
int remove_process(struct process_group *pgroup, int pid);
|
||||
|
||||
#endif
|
49
deps/cpulimit-fork/src/process_iterator.c
vendored
Normal file
49
deps/cpulimit-fork/src/process_iterator.c
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
/**
|
||||
*
|
||||
* cpulimit - a CPU limiter for Linux
|
||||
*
|
||||
* Copyright (C) 2005-2012, by: Angelo Marletta <angelo dot marletta at gmail dot com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifndef __APPLE__
|
||||
#include <sys/procfs.h>
|
||||
#endif
|
||||
#include <time.h>
|
||||
#include "process_iterator.h"
|
||||
|
||||
//See this link to port to other systems: http://www.steve.org.uk/Reference/Unix/faq_8.html#SEC85
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
#include "process_iterator_linux.c"
|
||||
|
||||
#elif defined __FreeBSD__
|
||||
|
||||
#include "process_iterator_freebsd.c"
|
||||
|
||||
#elif defined __APPLE__
|
||||
|
||||
#include "process_iterator_apple.c"
|
||||
|
||||
#else
|
||||
|
||||
#error Platform not supported
|
||||
|
||||
#endif
|
101
deps/cpulimit-fork/src/process_iterator.h
vendored
Normal file
101
deps/cpulimit-fork/src/process_iterator.h
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
/**
|
||||
*
|
||||
* cpulimit - a CPU limiter for Linux
|
||||
*
|
||||
* Copyright (C) 2005-2012, by: Angelo Marletta <angelo dot marletta at gmail dot com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __PROCESS_ITERATOR_H
|
||||
|
||||
#define __PROCESS_ITERATOR_H
|
||||
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <dirent.h>
|
||||
|
||||
//USER_HZ detection, from openssl code
|
||||
#ifndef HZ
|
||||
# if defined(_SC_CLK_TCK) \
|
||||
&& (!defined(OPENSSL_SYS_VMS) || __CTRL_VER >= 70000000)
|
||||
# define HZ ((double)sysconf(_SC_CLK_TCK))
|
||||
# else
|
||||
# ifndef CLK_TCK
|
||||
# ifndef _BSD_CLK_TCK_ /* FreeBSD hack */
|
||||
# define HZ 100.0
|
||||
# else /* _BSD_CLK_TCK_ */
|
||||
# define HZ ((double)_BSD_CLK_TCK_)
|
||||
# endif
|
||||
# else /* CLK_TCK */
|
||||
# define HZ ((double)CLK_TCK)
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include <kvm.h>
|
||||
#endif
|
||||
|
||||
// process descriptor
|
||||
struct process {
|
||||
//pid of the process
|
||||
pid_t pid;
|
||||
//ppid of the process
|
||||
pid_t ppid;
|
||||
//start time (unix timestamp)
|
||||
int starttime;
|
||||
//cputime used by the process (in milliseconds)
|
||||
int cputime;
|
||||
//actual cpu usage estimation (value in range 0-1)
|
||||
double cpu_usage;
|
||||
//absolute path of the executable file
|
||||
char command[PATH_MAX+1];
|
||||
};
|
||||
|
||||
struct process_filter {
|
||||
int pid;
|
||||
int include_children;
|
||||
char program_name[PATH_MAX+1];
|
||||
};
|
||||
|
||||
struct process_iterator {
|
||||
#ifdef __linux__
|
||||
DIR *dip;
|
||||
int boot_time;
|
||||
#elif defined __FreeBSD__
|
||||
kvm_t *kd;
|
||||
struct kinfo_proc *procs;
|
||||
int count;
|
||||
int i;
|
||||
#elif defined __APPLE__
|
||||
int i;
|
||||
int count;
|
||||
int *pidlist;
|
||||
#endif
|
||||
struct process_filter *filter;
|
||||
};
|
||||
|
||||
#ifdef __linux__
|
||||
int read_process_info(pid_t pid, struct process *p);
|
||||
#endif
|
||||
|
||||
int init_process_iterator(struct process_iterator *i, struct process_filter *filter);
|
||||
|
||||
int get_next_process(struct process_iterator *i, struct process *p);
|
||||
|
||||
int close_process_iterator(struct process_iterator *i);
|
||||
|
||||
#endif
|
148
deps/cpulimit-fork/src/process_iterator_apple.c
vendored
Normal file
148
deps/cpulimit-fork/src/process_iterator_apple.c
vendored
Normal file
@ -0,0 +1,148 @@
|
||||
/**
|
||||
*
|
||||
* cpulimit - a CPU limiter for Linux
|
||||
*
|
||||
* Copyright (C) 2005-2012, by: Angelo Marletta <angelo dot marletta at gmail dot com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Author: Simon Sigurdhsson
|
||||
*
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <libproc.h>
|
||||
|
||||
int unique_nonzero_ints(int* arr_in, int len_in, int* arr_out) {
|
||||
int* source = arr_in;
|
||||
if (arr_out == NULL) return -1;
|
||||
if (arr_in == arr_out) {
|
||||
source = malloc(sizeof(int)*len_in);
|
||||
memcpy(source, arr_in, sizeof(int)*len_in);
|
||||
memset(arr_out, -1, sizeof(int)*len_in);
|
||||
}
|
||||
int len_out = 0;
|
||||
int i, j;
|
||||
for (i=0; i<len_in; i++) {
|
||||
int found = 0;
|
||||
if (source[i] == 0) continue;
|
||||
for (j=0; !found && j<len_out; j++) {
|
||||
found = (source[i] == arr_out[j]) ? 1 : 0;
|
||||
}
|
||||
if (!found) {
|
||||
arr_out[len_out++] = source[i];
|
||||
}
|
||||
}
|
||||
if (arr_in == arr_out) {
|
||||
free(source);
|
||||
}
|
||||
return len_out-1;
|
||||
}
|
||||
|
||||
int init_process_iterator(struct process_iterator *it, struct process_filter *filter) {
|
||||
it->i = 0;
|
||||
/* Find out how much to allocate for it->pidlist */
|
||||
if ((it->count = proc_listpids(PROC_ALL_PIDS, 0, NULL, 0)) <= 0) {
|
||||
fprintf(stderr, "proc_listpids: %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
/* Allocate and populate it->pidlist */
|
||||
if ((it->pidlist = (int *)malloc((it->count)*sizeof(int))) == NULL) {
|
||||
fprintf(stderr, "malloc: %s\n", strerror(errno));
|
||||
}
|
||||
if ((it->count = proc_listpids(PROC_ALL_PIDS, 0, it->pidlist, it->count)) <= 0) {
|
||||
fprintf(stderr, "proc_listpids: %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
it->count = unique_nonzero_ints(it->pidlist, it->count, it->pidlist);
|
||||
it->filter = filter;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pti2proc(struct proc_taskallinfo *ti, struct process *process) {
|
||||
int bytes;
|
||||
process->pid = ti->pbsd.pbi_pid;
|
||||
process->ppid = ti->pbsd.pbi_ppid;
|
||||
process->starttime = ti->pbsd.pbi_start_tvsec;
|
||||
process->cputime = (ti->ptinfo.pti_total_user + ti->ptinfo.pti_total_system) / 1000000;
|
||||
bytes = strlen(ti->pbsd.pbi_comm);
|
||||
memcpy(process->command, ti->pbsd.pbi_comm, (bytes < PATH_MAX ? bytes : PATH_MAX) + 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_process_pti(pid_t pid, struct proc_taskallinfo *ti) {
|
||||
int bytes;
|
||||
bytes = proc_pidinfo(pid, PROC_PIDTASKALLINFO, 0, ti, sizeof(*ti));
|
||||
if (bytes <= 0) {
|
||||
if (!(errno & (EPERM | ESRCH))) {
|
||||
fprintf(stderr, "proc_pidinfo: %s\n", strerror(errno));
|
||||
}
|
||||
return -1;
|
||||
} else if (bytes < sizeof(ti)) {
|
||||
fprintf(stderr, "proc_pidinfo: too few bytes; expected %ld, got %d\n", sizeof(ti), bytes);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_next_process(struct process_iterator *it, struct process *p) {
|
||||
if (it->i == it->count) return -1;
|
||||
if (it->filter->pid != 0 && !it->filter->include_children) {
|
||||
struct proc_taskallinfo ti;
|
||||
if (get_process_pti(it->filter->pid, &ti) != 0) {
|
||||
it->i = it->count = 0;
|
||||
return -1;
|
||||
}
|
||||
it->i = it->count = 1;
|
||||
return pti2proc(&ti, p);
|
||||
}
|
||||
while (it->i < it->count) {
|
||||
struct proc_taskallinfo ti;
|
||||
if (get_process_pti(it->pidlist[it->i], &ti) != 0) {
|
||||
it->i++;
|
||||
continue;
|
||||
}
|
||||
if (ti.pbsd.pbi_flags & PROC_FLAG_SYSTEM) {
|
||||
it->i++;
|
||||
continue;
|
||||
}
|
||||
if (it->filter->pid != 0 && it->filter->include_children) {
|
||||
pti2proc(&ti, p);
|
||||
it->i++;
|
||||
if (p->pid != it->pidlist[it->i - 1]) // I don't know why this can happen
|
||||
continue;
|
||||
if (p->pid != it->filter->pid && p->ppid != it->filter->pid)
|
||||
continue;
|
||||
return 0;
|
||||
}
|
||||
else if (it->filter->pid == 0)
|
||||
{
|
||||
pti2proc(&ti, p);
|
||||
it->i++;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int close_process_iterator(struct process_iterator *it) {
|
||||
free(it->pidlist);
|
||||
it->pidlist = NULL;
|
||||
it->filter = NULL;
|
||||
it->count = 0;
|
||||
it->i = 0;
|
||||
return 0;
|
||||
}
|
119
deps/cpulimit-fork/src/process_iterator_freebsd.c
vendored
Normal file
119
deps/cpulimit-fork/src/process_iterator_freebsd.c
vendored
Normal file
@ -0,0 +1,119 @@
|
||||
/**
|
||||
*
|
||||
* cpulimit - a CPU limiter for Linux
|
||||
*
|
||||
* Copyright (C) 2005-2012, by: Angelo Marletta <angelo dot marletta at gmail dot com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/user.h>
|
||||
#include <fcntl.h>
|
||||
#include <paths.h>
|
||||
|
||||
int init_process_iterator(struct process_iterator *it, struct process_filter *filter) {
|
||||
char errbuf[_POSIX2_LINE_MAX];
|
||||
it->i = 0;
|
||||
/* Open the kvm interface, get a descriptor */
|
||||
if ((it->kd = kvm_openfiles(NULL, _PATH_DEVNULL, NULL, O_RDONLY, errbuf)) == NULL) {
|
||||
fprintf(stderr, "kvm_open: %s\n", errbuf);
|
||||
return -1;
|
||||
}
|
||||
/* Get the list of processes. */
|
||||
if ((it->procs = kvm_getprocs(it->kd, KERN_PROC_PROC, 0, &it->count)) == NULL) {
|
||||
kvm_close(it->kd);
|
||||
// fprintf(stderr, "kvm_getprocs: %s\n", kvm_geterr(it->kd));
|
||||
return -1;
|
||||
}
|
||||
it->filter = filter;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int kproc2proc(kvm_t *kd, struct kinfo_proc *kproc, struct process *proc)
|
||||
{
|
||||
proc->pid = kproc->ki_pid;
|
||||
proc->ppid = kproc->ki_ppid;
|
||||
proc->cputime = kproc->ki_runtime / 1000;
|
||||
proc->starttime = kproc->ki_start.tv_sec;
|
||||
char **args = kvm_getargv(kd, kproc, sizeof(proc->command));
|
||||
if (args == NULL) return -1;
|
||||
memcpy(proc->command, args[0], strlen(args[0]) + 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_single_process(kvm_t *kd, pid_t pid, struct process *process)
|
||||
{
|
||||
int count;
|
||||
struct kinfo_proc *kproc = kvm_getprocs(kd, KERN_PROC_PID, pid, &count);
|
||||
if (count == 0 || kproc == NULL)
|
||||
{
|
||||
// fprintf(stderr, "kvm_getprocs: %s\n", kvm_geterr(kd));
|
||||
return -1;
|
||||
}
|
||||
kproc2proc(kd, kproc, process);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_next_process(struct process_iterator *it, struct process *p) {
|
||||
if (it->i == it->count)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (it->filter->pid != 0 && !it->filter->include_children)
|
||||
{
|
||||
if (get_single_process(it->kd, it->filter->pid, p) != 0)
|
||||
{
|
||||
it->i = it->count = 0;
|
||||
return -1;
|
||||
}
|
||||
it->i = it->count = 1;
|
||||
return 0;
|
||||
}
|
||||
while (it->i < it->count)
|
||||
{
|
||||
struct kinfo_proc *kproc = &(it->procs[it->i]);
|
||||
if (kproc->ki_flag & P_SYSTEM)
|
||||
{
|
||||
// skip system processes
|
||||
it->i++;
|
||||
continue;
|
||||
}
|
||||
if (it->filter->pid != 0 && it->filter->include_children)
|
||||
{
|
||||
kproc2proc(it->kd, kproc, p);
|
||||
it->i++;
|
||||
if (p->pid != it->filter->pid && p->ppid != it->filter->pid)
|
||||
continue;
|
||||
return 0;
|
||||
}
|
||||
else if (it->filter->pid == 0)
|
||||
{
|
||||
kproc2proc(it->kd, kproc, p);
|
||||
it->i++;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int close_process_iterator(struct process_iterator *it) {
|
||||
if (kvm_close(it->kd) == -1) {
|
||||
fprintf(stderr, "kvm_getprocs: %s\n", kvm_geterr(it->kd));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
181
deps/cpulimit-fork/src/process_iterator_linux.c
vendored
Normal file
181
deps/cpulimit-fork/src/process_iterator_linux.c
vendored
Normal file
@ -0,0 +1,181 @@
|
||||
/**
|
||||
*
|
||||
* cpulimit - a CPU limiter for Linux
|
||||
*
|
||||
* Copyright (C) 2005-2012, by: Angelo Marletta <angelo dot marletta at gmail dot com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <sys/vfs.h>
|
||||
|
||||
static int get_boot_time()
|
||||
{
|
||||
int uptime = 0;
|
||||
FILE *fp = fopen ("/proc/uptime", "r");
|
||||
if (fp != NULL)
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
char *b = fgets(buf, BUFSIZ, fp);
|
||||
if (b == buf)
|
||||
{
|
||||
char *end_ptr;
|
||||
double upsecs = strtod(buf, &end_ptr);
|
||||
uptime = (int)upsecs;
|
||||
}
|
||||
fclose (fp);
|
||||
}
|
||||
time_t now = time(NULL);
|
||||
return now - uptime;
|
||||
}
|
||||
|
||||
static int check_proc()
|
||||
{
|
||||
struct statfs mnt;
|
||||
if (statfs("/proc", &mnt) < 0)
|
||||
return 0;
|
||||
if (mnt.f_type!=0x9fa0)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int init_process_iterator(struct process_iterator *it, struct process_filter *filter)
|
||||
{
|
||||
if (!check_proc()) {
|
||||
fprintf(stderr, "procfs is not mounted!\nAborting\n");
|
||||
exit(-2);
|
||||
}
|
||||
//open a directory stream to /proc directory
|
||||
if ((it->dip = opendir("/proc")) == NULL)
|
||||
{
|
||||
perror("opendir");
|
||||
return -1;
|
||||
}
|
||||
it->filter = filter;
|
||||
it->boot_time = get_boot_time();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int read_process_info(pid_t pid, struct process *p)
|
||||
{
|
||||
static char buffer[1024];
|
||||
static char statfile[32];
|
||||
static char exefile[1024];
|
||||
p->pid = pid;
|
||||
//read stat file
|
||||
sprintf(statfile, "/proc/%d/stat", p->pid);
|
||||
FILE *fd = fopen(statfile, "r");
|
||||
if (fd==NULL) return -1;
|
||||
if (fgets(buffer, sizeof(buffer), fd)==NULL) {
|
||||
fclose(fd);
|
||||
return -1;
|
||||
}
|
||||
fclose(fd);
|
||||
char *token = strtok(buffer, " ");
|
||||
int i;
|
||||
for (i=0; i<3; i++) token = strtok(NULL, " ");
|
||||
p->ppid = atoi(token);
|
||||
for (i=0; i<10; i++)
|
||||
token = strtok(NULL, " ");
|
||||
p->cputime = atoi(token) * 1000 / HZ;
|
||||
token = strtok(NULL, " ");
|
||||
p->cputime += atoi(token) * 1000 / HZ;
|
||||
for (i=0; i<7; i++)
|
||||
token = strtok(NULL, " ");
|
||||
p->starttime = atoi(token) / sysconf(_SC_CLK_TCK);
|
||||
//read command line
|
||||
sprintf(exefile,"/proc/%d/cmdline", p->pid);
|
||||
fd = fopen(exefile, "r");
|
||||
if (fgets(buffer, sizeof(buffer), fd)==NULL) {
|
||||
fclose(fd);
|
||||
return -1;
|
||||
}
|
||||
fclose(fd);
|
||||
strcpy(p->command, buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static pid_t getppid_of(pid_t pid)
|
||||
{
|
||||
char statfile[20];
|
||||
char buffer[1024];
|
||||
sprintf(statfile, "/proc/%d/stat", pid);
|
||||
FILE *fd = fopen(statfile, "r");
|
||||
if (fd==NULL) return -1;
|
||||
if (fgets(buffer, sizeof(buffer), fd)==NULL) {
|
||||
fclose(fd);
|
||||
return -1;
|
||||
}
|
||||
fclose(fd);
|
||||
char *token = strtok(buffer, " ");
|
||||
int i;
|
||||
for (i=0; i<3; i++) token = strtok(NULL, " ");
|
||||
return atoi(token);
|
||||
}
|
||||
|
||||
static int is_child_of(pid_t child_pid, pid_t parent_pid)
|
||||
{
|
||||
int ppid = child_pid;
|
||||
while(ppid > 1 && ppid != parent_pid) {
|
||||
ppid = getppid_of(ppid);
|
||||
}
|
||||
return ppid == parent_pid;
|
||||
}
|
||||
|
||||
int get_next_process(struct process_iterator *it, struct process *p)
|
||||
{
|
||||
if (it->dip == NULL)
|
||||
{
|
||||
//end of processes
|
||||
return -1;
|
||||
}
|
||||
if (it->filter->pid != 0 && !it->filter->include_children)
|
||||
{
|
||||
int ret = read_process_info(it->filter->pid, p);
|
||||
//p->starttime += it->boot_time;
|
||||
closedir(it->dip);
|
||||
it->dip = NULL;
|
||||
if (ret != 0) return -1;
|
||||
return 0;
|
||||
}
|
||||
struct dirent *dit = NULL;
|
||||
//read in from /proc and seek for process dirs
|
||||
while ((dit = readdir(it->dip)) != NULL) {
|
||||
if(strtok(dit->d_name, "0123456789") != NULL)
|
||||
continue;
|
||||
p->pid = atoi(dit->d_name);
|
||||
if (it->filter->pid != 0 && it->filter->pid != p->pid && !is_child_of(p->pid, it->filter->pid)) continue;
|
||||
read_process_info(p->pid, p);
|
||||
//p->starttime += it->boot_time;
|
||||
break;
|
||||
}
|
||||
if (dit == NULL)
|
||||
{
|
||||
//end of processes
|
||||
closedir(it->dip);
|
||||
it->dip = NULL;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int close_process_iterator(struct process_iterator *it) {
|
||||
if (it->dip != NULL && closedir(it->dip) == -1) {
|
||||
perror("closedir");
|
||||
return 1;
|
||||
}
|
||||
it->dip = NULL;
|
||||
return 0;
|
||||
}
|
23
deps/cpulimit-fork/tests/Makefile
vendored
Normal file
23
deps/cpulimit-fork/tests/Makefile
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
CC?=gcc
|
||||
CFLAGS?=-Wall -g
|
||||
TARGETS=busy process_iterator_test
|
||||
SRC=../src
|
||||
SYSLIBS?=-lpthread
|
||||
LIBS=$(SRC)/list.o $(SRC)/process_iterator.o $(SRC)/process_group.o
|
||||
UNAME := $(shell uname)
|
||||
|
||||
ifeq ($(UNAME), FreeBSD)
|
||||
LIBS+=-lkvm
|
||||
endif
|
||||
|
||||
all:: $(TARGETS)
|
||||
|
||||
busy: busy.c
|
||||
$(CC) -o busy busy.c $(SYSLIBS) $(CFLAGS)
|
||||
|
||||
process_iterator_test: process_iterator_test.c $(LIBS)
|
||||
$(CC) -I$(SRC) -o process_iterator_test process_iterator_test.c $(LIBS) $(SYSLIBS) $(CFLAGS)
|
||||
|
||||
clean:
|
||||
rm -f *~ *.o $(TARGETS)
|
||||
|
29
deps/cpulimit-fork/tests/busy.c
vendored
Normal file
29
deps/cpulimit-fork/tests/busy.c
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void *loop()
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
int i = 0;
|
||||
int num_threads = 1;
|
||||
if (argc == 2) num_threads = atoi(argv[1]);
|
||||
for (i=0; i<num_threads-1; i++)
|
||||
{
|
||||
pthread_t thread;
|
||||
int ret;
|
||||
if ((ret = pthread_create(&thread, NULL, loop, NULL)) != 0)
|
||||
{
|
||||
printf("pthread_create() failed. Error code %d\n", ret);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
loop();
|
||||
return 0;
|
||||
}
|
||||
|
242
deps/cpulimit-fork/tests/process_iterator_test.c
vendored
Normal file
242
deps/cpulimit-fork/tests/process_iterator_test.c
vendored
Normal file
@ -0,0 +1,242 @@
|
||||
/**
|
||||
*
|
||||
* cpulimit - a CPU limiter for Linux
|
||||
*
|
||||
* Copyright (C) 2005-2012, by: Angelo Marletta <angelo dot marletta at gmail dot com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
#include <time.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __APPLE__ || __FREEBSD__
|
||||
#include <libgen.h>
|
||||
#endif
|
||||
|
||||
#include <process_iterator.h>
|
||||
#include <process_group.h>
|
||||
|
||||
volatile sig_atomic_t child;
|
||||
|
||||
void kill_child(int sig)
|
||||
{
|
||||
kill(child, SIGINT);
|
||||
}
|
||||
|
||||
void test_single_process()
|
||||
{
|
||||
struct process_iterator it;
|
||||
struct process process;
|
||||
struct process_filter filter;
|
||||
int count;
|
||||
//don't iterate children
|
||||
filter.pid = getpid();
|
||||
filter.include_children = 0;
|
||||
count = 0;
|
||||
// time_t now = time(NULL);
|
||||
init_process_iterator(&it, &filter);
|
||||
while (get_next_process(&it, &process) == 0)
|
||||
{
|
||||
assert(process.pid == getpid());
|
||||
assert(process.ppid == getppid());
|
||||
assert(process.cputime < 100);
|
||||
// assert(process.starttime == now || process.starttime == now - 1);
|
||||
count++;
|
||||
}
|
||||
assert(count == 1);
|
||||
close_process_iterator(&it);
|
||||
//iterate children
|
||||
filter.pid = getpid();
|
||||
filter.include_children = 0;
|
||||
count = 0;
|
||||
// now = time(NULL);
|
||||
init_process_iterator(&it, &filter);
|
||||
while (get_next_process(&it, &process) == 0)
|
||||
{
|
||||
assert(process.pid == getpid());
|
||||
assert(process.ppid == getppid());
|
||||
assert(process.cputime < 100);
|
||||
// assert(process.starttime == now || process.starttime == now - 1);
|
||||
count++;
|
||||
}
|
||||
assert(count == 1);
|
||||
close_process_iterator(&it);
|
||||
}
|
||||
|
||||
void test_multiple_process()
|
||||
{
|
||||
struct process_iterator it;
|
||||
struct process process;
|
||||
struct process_filter filter;
|
||||
pid_t child = fork();
|
||||
if (child == 0)
|
||||
{
|
||||
//child is supposed to be killed by the parent :/
|
||||
sleep(1);
|
||||
exit(1);
|
||||
}
|
||||
filter.pid = getpid();
|
||||
filter.include_children = 1;
|
||||
init_process_iterator(&it, &filter);
|
||||
int count = 0;
|
||||
// time_t now = time(NULL);
|
||||
while (get_next_process(&it, &process) == 0)
|
||||
{
|
||||
if (process.pid == getpid()) assert(process.ppid == getppid());
|
||||
else if (process.pid == child) assert(process.ppid == getpid());
|
||||
else assert(0);
|
||||
assert(process.cputime < 100);
|
||||
// assert(process.starttime == now || process.starttime == now - 1);
|
||||
count++;
|
||||
}
|
||||
assert(count == 2);
|
||||
close_process_iterator(&it);
|
||||
kill(child, SIGINT);
|
||||
}
|
||||
|
||||
void test_all_processes()
|
||||
{
|
||||
struct process_iterator it;
|
||||
struct process process;
|
||||
struct process_filter filter;
|
||||
filter.pid = 0;
|
||||
filter.include_children = 0;
|
||||
init_process_iterator(&it, &filter);
|
||||
int count = 0;
|
||||
// time_t now = time(NULL);
|
||||
while (get_next_process(&it, &process) == 0)
|
||||
{
|
||||
if (process.pid == getpid())
|
||||
{
|
||||
assert(process.ppid == getppid());
|
||||
assert(process.cputime < 100);
|
||||
// assert(process.starttime == now || process.starttime == now - 1);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
assert(count >= 10);
|
||||
close_process_iterator(&it);
|
||||
}
|
||||
|
||||
void test_process_group_all()
|
||||
{
|
||||
struct process_group pgroup;
|
||||
assert(init_process_group(&pgroup, 0, 0) == 0);
|
||||
update_process_group(&pgroup);
|
||||
struct list_node *node = NULL;
|
||||
int count = 0;
|
||||
for (node=pgroup.proclist->first; node!= NULL; node=node->next) {
|
||||
count++;
|
||||
}
|
||||
assert(count > 10);
|
||||
update_process_group(&pgroup);
|
||||
assert(close_process_group(&pgroup) == 0);
|
||||
}
|
||||
|
||||
void test_process_group_single(int include_children)
|
||||
{
|
||||
struct process_group pgroup;
|
||||
child = fork();
|
||||
if (child == 0)
|
||||
{
|
||||
//child is supposed to be killed by the parent :/
|
||||
while(1);
|
||||
exit(1);
|
||||
}
|
||||
signal(SIGABRT, &kill_child);
|
||||
signal(SIGTERM, &kill_child);
|
||||
assert(init_process_group(&pgroup, child, include_children) == 0);
|
||||
int i;
|
||||
double tot_usage = 0;
|
||||
for (i=0; i<100; i++)
|
||||
{
|
||||
update_process_group(&pgroup);
|
||||
struct list_node *node = NULL;
|
||||
int count = 0;
|
||||
for (node=pgroup.proclist->first; node!= NULL; node=node->next) {
|
||||
struct process *p = (struct process*)(node->data);
|
||||
assert(p->pid == child);
|
||||
assert(p->ppid == getpid());
|
||||
assert(p->cpu_usage <= 1.2);
|
||||
tot_usage += p->cpu_usage;
|
||||
count++;
|
||||
}
|
||||
assert(count == 1);
|
||||
struct timespec interval;
|
||||
interval.tv_sec = 0;
|
||||
interval.tv_nsec = 50000000;
|
||||
nanosleep(&interval, NULL);
|
||||
}
|
||||
assert(tot_usage / i < 1.1 && tot_usage / i > 0.8);
|
||||
assert(close_process_group(&pgroup) == 0);
|
||||
kill(child, SIGINT);
|
||||
}
|
||||
|
||||
void test_process_name(const char * command)
|
||||
{
|
||||
struct process_iterator it;
|
||||
struct process process;
|
||||
struct process_filter filter;
|
||||
filter.pid = getpid();
|
||||
filter.include_children = 0;
|
||||
init_process_iterator(&it, &filter);
|
||||
assert(get_next_process(&it, &process) == 0);
|
||||
assert(process.pid == getpid());
|
||||
assert(process.ppid == getppid());
|
||||
#ifdef __APPLE__
|
||||
// proc_pidinfo only gives us the first 15 chars
|
||||
// of the basename of the command on OSX.
|
||||
assert(strncmp(basename((char*)command), process.command, 15) == 0);
|
||||
#else
|
||||
assert(strncmp(command, process.command, strlen(process.command)) == 0);
|
||||
#endif
|
||||
assert(get_next_process(&it, &process) != 0);
|
||||
close_process_iterator(&it);
|
||||
}
|
||||
|
||||
void test_process_group_wrong_pid()
|
||||
{
|
||||
struct process_group pgroup;
|
||||
assert(init_process_group(&pgroup, -1, 0) == 0);
|
||||
assert(pgroup.proclist->count == 0);
|
||||
update_process_group(&pgroup);
|
||||
assert(pgroup.proclist->count == 0);
|
||||
assert(init_process_group(&pgroup, 9999999, 0) == 0);
|
||||
assert(pgroup.proclist->count == 0);
|
||||
update_process_group(&pgroup);
|
||||
assert(pgroup.proclist->count == 0);
|
||||
assert(close_process_group(&pgroup) == 0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// printf("Pid %d\n", getpid());
|
||||
test_single_process();
|
||||
test_multiple_process();
|
||||
test_all_processes();
|
||||
test_process_group_all();
|
||||
test_process_group_single(0);
|
||||
test_process_group_single(1);
|
||||
test_process_group_wrong_pid();
|
||||
test_process_name(argv[0]);
|
||||
return 0;
|
||||
}
|
0
deps/cpulimit-fork/tests/run_tests.sh
vendored
Normal file
0
deps/cpulimit-fork/tests/run_tests.sh
vendored
Normal file
Loading…
Reference in New Issue
Block a user