]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/basic/process-util.h
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / basic / process-util.h
index 28d8d7499a5060fde2126ab50cbac1937a142dcb..d99fb3d6b84fbdf458953bb3e65bb78251593cf4 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 #pragma once
 
 /***
@@ -20,6 +21,7 @@
 ***/
 
 #include <alloca.h>
+#include <sched.h>
 #include <signal.h>
 #include <stdbool.h>
 #include <stddef.h>
@@ -90,6 +92,9 @@ bool oom_score_adjust_is_valid(int oa);
 unsigned long personality_from_string(const char *p);
 const char *personality_to_string(unsigned long);
 
+int safe_personality(unsigned long p);
+int opinionated_personality(unsigned long *ret);
+
 int ioprio_class_to_string_alloc(int i, char **s);
 int ioprio_class_from_string(const char *s);
 
@@ -110,6 +115,14 @@ static inline bool nice_is_valid(int n) {
         return n >= PRIO_MIN && n < PRIO_MAX;
 }
 
+static inline bool sched_policy_is_valid(int i) {
+        return IN_SET(i, SCHED_OTHER, SCHED_BATCH, SCHED_IDLE, SCHED_FIFO, SCHED_RR);
+}
+
+static inline bool sched_priority_is_valid(int i) {
+        return i >= 0 && i <= sched_get_priority_max(SCHED_RR);
+}
+
 static inline bool ioprio_class_is_valid(int i) {
         return IN_SET(i, IOPRIO_CLASS_NONE, IOPRIO_CLASS_RT, IOPRIO_CLASS_BE, IOPRIO_CLASS_IDLE);
 }
@@ -118,4 +131,10 @@ static inline bool ioprio_priority_is_valid(int i) {
         return i >= 0 && i < IOPRIO_BE_NR;
 }
 
+static inline bool pid_is_valid(pid_t p) {
+        return p > 0;
+}
+
 int ioprio_parse_priority(const char *s, int *ret);
+
+pid_t getpid_cached(void);