pidref: add new pidref_is_self() helper
This simply checks if the specified PidRef refers to the process we are running in. (In case you wonder why this is not a static inline: to avoid cyclic header inclusion problems between pidref.h + process-util.h)
This commit is contained in:
@@ -263,6 +263,13 @@ int pidref_verify(const PidRef *pidref) {
|
||||
return 1; /* We have a pidfd and it still points to the PID we have, hence all is *really* OK → return 1 */
|
||||
}
|
||||
|
||||
bool pidref_is_self(const PidRef *pidref) {
|
||||
if (!pidref)
|
||||
return false;
|
||||
|
||||
return pidref->pid == getpid_cached();
|
||||
}
|
||||
|
||||
static void pidref_hash_func(const PidRef *pidref, struct siphash *state) {
|
||||
siphash24_compress(&pidref->pid, sizeof(pidref->pid), state);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user