sd-json: add sd_json_dispatch_pid()

This commit is contained in:
Ivan Kruglov
2024-10-10 11:35:30 +02:00
parent f6cb4d4afb
commit dafd44de4f
4 changed files with 52 additions and 0 deletions

View File

@@ -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);