Package: suckless-tools / 48-1

Don-t-exit-if-failed-to-adjust-OOM-score.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
From: Ilias Tsitsimpis <i.tsitsimpis@gmail.com>
Date: Tue, 13 Oct 2015 15:27:46 +0300
Subject: slock: Don't exit if failed to adjust OOM score

Adjusting the OOM score needs CAP_SYS_RESOURCE capabilities or the
setuid bit. But we don't want to setuid our binary and not all
filesystems support setting capabilities to executables. Modify slock
to not fail if it cannot adjust the OOM score.

Forwarded: no (Debian specific)
---
 slock/slock.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/slock/slock.c b/slock/slock.c
index 5ae738c..8f92a1b 100644
--- a/slock/slock.c
+++ b/slock/slock.c
@@ -70,15 +70,18 @@ dontkillme(void)
 	if (!(f = fopen(oomfile, "w"))) {
 		if (errno == ENOENT)
 			return;
-		die("slock: fopen %s: %s\n", oomfile, strerror(errno));
+		fprintf(stderr, "cannot disable the out-of-memory"
+			" killer for this process\n");
+		return;
 	}
 	fprintf(f, "%d", OOM_SCORE_ADJ_MIN);
 	if (fclose(f)) {
 		if (errno == EACCES)
-			die("slock: unable to disable OOM killer. "
-			    "Make sure to suid or sgid slock.\n");
+			fprintf(stderr, "cannot disable the out-of-memory"
+				" killer for this process\n");
 		else
-			die("slock: fclose %s: %s\n", oomfile, strerror(errno));
+			fprintf(stderr, "cannot disable the out-of-memory"
+				" killer for this process\n");
 	}
 }
 #endif