]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/pidref.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
6 /* An embeddable structure carrying a reference to a process. Supposed to be used when tracking processes continuously. */
7 typedef struct PidRef
{
8 pid_t pid
; /* always valid */
9 int fd
; /* only valid if pidfd are available in the kernel, and we manage to get an fd */
12 #define PIDREF_NULL (PidRef) { .fd = -EBADF }
14 static inline bool pidref_is_set(const PidRef
*pidref
) {
15 return pidref
&& pidref
->pid
> 0;
18 int pidref_set_pid(PidRef
*pidref
, pid_t pid
);
19 int pidref_set_pidstr(PidRef
*pidref
, const char *pid
);
20 int pidref_set_pidfd(PidRef
*pidref
, int fd
);
21 int pidref_set_pidfd_take(PidRef
*pidref
, int fd
); /* takes ownership of the passed pidfd on success*/
22 int pidref_set_pidfd_consume(PidRef
*pidref
, int fd
); /* takes ownership of the passed pidfd in both success and failure */
24 void pidref_done(PidRef
*pidref
);
26 int pidref_kill(PidRef
*pidref
, int sig
);
27 int pidref_kill_and_sigcont(PidRef
*pidref
, int sig
);
28 int pidref_sigqueue(PidRef
*pidfref
, int sig
, int value
);
30 #define TAKE_PIDREF(p) TAKE_GENERIC((p), PidRef, PIDREF_NULL)