summaryrefslogtreecommitdiff
path: root/src/basic/process-util.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-08-05 11:17:08 +0200
committerLennart Poettering <lennart@poettering.net>2016-08-05 11:18:32 +0200
commit41bf0590cc89438f1d319465190b1c00809c78fe (patch)
tree58d255848f99af24009cea575d4d58ec53d6874d /src/basic/process-util.h
parent1ed1f50f8277df07918e13cba3331a114eaa6fe3 (diff)
util-lib: unify parsing of nice level values
This adds parse_nice() that parses a nice level and ensures it is in the right range, via a new nice_is_valid() helper. It then ports over a number of users to this. No functional changes.
Diffstat (limited to 'src/basic/process-util.h')
-rw-r--r--src/basic/process-util.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/basic/process-util.h b/src/basic/process-util.h
index 9f75088796..2568e3834f 100644
--- a/src/basic/process-util.h
+++ b/src/basic/process-util.h
@@ -26,6 +26,7 @@
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
+#include <sys/resource.h>
#include "formats-util.h"
#include "macro.h"
@@ -103,3 +104,7 @@ int sched_policy_from_string(const char *s);
void valgrind_summary_hack(void);
int pid_compare_func(const void *a, const void *b);
+
+static inline bool nice_is_valid(int n) {
+ return n >= PRIO_MIN && n < PRIO_MAX;
+}