#include "macro.h"
-/* An embeddable structure carrying a reference to a process. Supposed to be used when tracking processes continously. */
+/* An embeddable structure carrying a reference to a process. Supposed to be used when tracking processes continuously. */
typedef struct PidRef {
pid_t pid; /* always valid */
int fd; /* only valid if pidfd are available in the kernel, and we manage to get an fd */
return pidref && pidref->pid > 0;
}
+static inline bool pidref_equal(const PidRef *a, const PidRef *b) {
+
+ if (pidref_is_set(a)) {
+ if (!pidref_is_set(b))
+ return false;
+
+ return a->pid == b->pid;
+ }
+
+ return !pidref_is_set(b);
+}
+
int pidref_set_pid(PidRef *pidref, pid_t pid);
int pidref_set_pidstr(PidRef *pidref, const char *pid);
int pidref_set_pidfd(PidRef *pidref, int fd);