pidref: add PIDREF_MAKE_FROM_PID()

This helper truns a pid_t into a PidRef. It's different from
pidref_set_pid() in being "passive", i.e. it does not attempt to acquire
a pidfd for the pid.

This is useful when using the PidRef as a lookup key that shall also
work after a process is already dead, and hence no conversion to a pidfd
is possible anymore.
This commit is contained in:
Lennart Poettering
2023-09-28 23:22:58 +02:00
parent 12c7d27b65
commit dcfcea6d02
2 changed files with 7 additions and 5 deletions
+1 -5
View File
@@ -68,11 +68,7 @@ int pidref_set_pidfd(PidRef *pidref, int fd) {
if (r < 0)
return r;
*pidref = (PidRef) {
.fd = -EBADF,
.pid = pid,
};
*pidref = PIDREF_MAKE_FROM_PID(pid);
return 0;
}