11/* SPDX-License-Identifier: LGPL-2.1-or-later */
22#pragma once
33
4- typedef struct PidRef PidRef ;
5-
64#include "macro.h"
7- #include "process -util.h"
5+ #include "memory -util.h"
86
97/* An embeddable structure carrying a reference to a process. Supposed to be used when tracking processes
108 * continuously. This combines a PID, a modern Linux pidfd and the 64bit inode number of the pidfd into one
@@ -29,22 +27,22 @@ typedef struct PidRef PidRef;
2927 * process. Moreover, most operations will fail with -EREMOTE. Only PidRef structures that are not marked
3028 * *unset* can be marked *remote*.
3129 */
32- struct PidRef {
33- pid_t pid ; /* > 0 if the PidRef is set, otherwise set to PID_AUTOMATIC if automatic mode is
34- * desired, or 0 otherwise. */
30+ typedef struct PidRef {
31+ pid_t pid ; /* > 0 if the PidRef is set, otherwise set to INT_MIN ( PID_AUTOMATIC) if automatic
32+ * mode is desired, or 0 otherwise. */
3533 int fd ; /* only valid if pidfd are available in the kernel, and we manage to get an fd. If we
3634 * know that the PID is not from the local machine we set this to -EREMOTE, otherwise
3735 * we use -EBADF as indicator the fd is invalid. */
3836 uint64_t fd_id ; /* the inode number of pidfd. only useful in kernel 6.9+ where pidfds live in
3937 their own pidfs and each process comes with a unique inode number */
40- };
38+ } PidRef ;
4139
4240#define PIDREF_NULL (PidRef) { .fd = -EBADF }
4341
4442/* A special pidref value that we are using when a PID shall be automatically acquired from some surrounding
4543 * context, for example connection peer. Much like PIDREF_NULL it will be considered unset by
4644 * pidref_is_set(). */
47- #define PIDREF_AUTOMATIC (const PidRef) { .pid = PID_AUTOMATIC , .fd = -EBADF }
45+ #define PIDREF_AUTOMATIC (const PidRef) { .pid = (pid_t) INT_MIN , .fd = -EBADF }
4846
4947/* Turns a pid_t into a PidRef structure on-the-fly *without* acquiring a pidfd for it. (As opposed to
5048 * pidref_set_pid() which does so *with* acquiring one, see below) */
0 commit comments