diff options
-rw-r--r-- | .SRCINFO | 2 | ||||
-rw-r--r-- | PKGBUILD | 2 | ||||
-rw-r--r-- | xscreensaver-oom-protect.c | 6 |
3 files changed, 7 insertions, 3 deletions
@@ -1,6 +1,6 @@ pkgbase = xscreensaver-oom-protect pkgdesc = Protect xscreensaver from the out-of-memory killer - pkgver = 1.0.0 + pkgver = 1.0.1 pkgrel = 1 arch = x86_64 license = custom:WTFPL @@ -1,7 +1,7 @@ # Maintainer: Alexander Kobel <a-kobel@a-kobel.de> pkgname=xscreensaver-oom-protect -pkgver=1.0.0 +pkgver=1.0.1 pkgrel=1 pkgdesc="Protect xscreensaver from the out-of-memory killer" arch=('x86_64') diff --git a/xscreensaver-oom-protect.c b/xscreensaver-oom-protect.c index 389b09012288..476883502d38 100644 --- a/xscreensaver-oom-protect.c +++ b/xscreensaver-oom-protect.c @@ -28,11 +28,12 @@ #include <stdlib.h> #include <string.h> #include <linux/oom.h> +#include <sys/resource.h> int usage (char **argv) { fprintf (stderr, "Protect process <pid> from the OOM killer by setting its " - "oom_score_adj to %d.\n" + "oom_score_adj to %d and its nice value to -20.\n" "(TL;DR: try to avoid that an attacker types Alt+SysRq+F " "repeatedly and ends up\n" "with your logged-in session without the xscreensaver lock.)\n" @@ -110,5 +111,8 @@ int main (int argc, char **argv) { fprintf (f, "%d", OOM_SCORE_ADJ_MIN); fclose (f); + if (setpriority (PRIO_PROCESS, pid, INT_MIN) != 0) + return errno; + return 0; } |