summaryrefslogtreecommitdiffstats
path: root/src/basic
diff options
context:
space:
mode:
authorIvan Kruglov <mail@ikruglov.com>2024-10-10 11:35:30 +0200
committerIvan Kruglov <mail@ikruglov.com>2024-10-10 13:40:45 +0200
commitdafd44de4f0c10c525b9ea4e5df7b6fc2fb18dbd (patch)
tree576180b20c7de90ca3c13bba4f66a532a3e2a0a3 /src/basic
parentmachine: switch to use PidRef when lookup machine by pid in dbus and varlink ... (diff)
downloadsystemd-dafd44de4f0c10c525b9ea4e5df7b6fc2fb18dbd.tar.xz
systemd-dafd44de4f0c10c525b9ea4e5df7b6fc2fb18dbd.zip
sd-json: add sd_json_dispatch_pid()
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/process-util.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/basic/process-util.h b/src/basic/process-util.h
index 59732a8676..2efe89e135 100644
--- a/src/basic/process-util.h
+++ b/src/basic/process-util.h
@@ -148,10 +148,21 @@ static inline bool sched_priority_is_valid(int i) {
return i >= 0 && i <= sched_get_priority_max(SCHED_RR);
}
+#define PID_AUTOMATIC ((pid_t) INT_MIN) /* special value indicating "acquire pid from connection peer */
+#define PID_INVALID ((pid_t) 0) /* default value for "invalid pid" */
+
static inline bool pid_is_valid(pid_t p) {
return p > 0;
}
+static inline bool pid_is_automatic(pid_t p) {
+ return p == PID_AUTOMATIC;
+}
+
+static inline bool pid_is_valid_or_automatic(pid_t p) {
+ return pid_is_valid(p) || pid_is_automatic(p);
+}
+
pid_t getpid_cached(void);
void reset_cached_pid(void);