diff options
author | Ivan Kruglov <mail@ikruglov.com> | 2024-10-10 11:35:30 +0200 |
---|---|---|
committer | Ivan Kruglov <mail@ikruglov.com> | 2024-10-10 13:40:45 +0200 |
commit | dafd44de4f0c10c525b9ea4e5df7b6fc2fb18dbd (patch) | |
tree | 576180b20c7de90ca3c13bba4f66a532a3e2a0a3 /src/basic | |
parent | machine: switch to use PidRef when lookup machine by pid in dbus and varlink ... (diff) | |
download | systemd-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.h | 11 |
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); |