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:
+1
-5
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user