Skip to content

Commit 793e187

Browse files
committed
basic: Remove circular dependency between process-util.h and pidref.h
1 parent 95609f3 commit 793e187

File tree

14 files changed

+21
-8
lines changed

14 files changed

+21
-8
lines changed

src/basic/capability-util.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "macro.h"
2121
#include "parse-util.h"
2222
#include "pidref.h"
23+
#include "process-util.h"
2324
#include "stat-util.h"
2425
#include "user-util.h"
2526

src/basic/pidref.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
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) */

src/libsystemd/sd-bus/bus-objects.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "bus-slot.h"
1212
#include "bus-type.h"
1313
#include "log.h"
14+
#include "set.h"
1415
#include "string-util.h"
1516
#include "strv.h"
1617

src/libsystemd/sd-bus/bus-slot.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "bus-objects.h"
88
#include "bus-slot.h"
99
#include "log.h"
10+
#include "set.h"
1011
#include "string-util.h"
1112

1213
sd_bus_slot *bus_slot_allocate(

src/login/logind-session-dbus.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "bus-util.h"
1111
#include "devnum-util.h"
1212
#include "fd-util.h"
13+
#include "format-util.h"
1314
#include "logind-brightness.h"
1415
#include "logind-dbus.h"
1516
#include "logind-polkit.h"

src/login/logind-utmp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "logind-utmp.h"
44
#include "path-util.h"
5+
#include "process-util.h"
56
#include "utmp-wtmp.h"
67

78
int manager_read_utmp(Manager *m) {

src/login/logind-varlink.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "cgroup-util.h"
44
#include "fd-util.h"
5+
#include "format-util.h"
56
#include "json-util.h"
67
#include "logind.h"
78
#include "logind-dbus.h"

src/machine/image-varlink.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "json-util.h"
1414
#include "machine.h"
1515
#include "machine-pool.h"
16+
#include "process-util.h"
1617
#include "string-util.h"
1718

1819
typedef struct ImageUpdateParameters {

src/ptyfwd/ptyfwd-tool.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "log.h"
1111
#include "main-func.h"
1212
#include "pretty-print.h"
13+
#include "process-util.h"
1314
#include "ptyfwd.h"
1415
#include "strv.h"
1516

src/shared/notify-recv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "fd-util.h"
55
#include "log.h"
66
#include "notify-recv.h"
7+
#include "process-util.h"
78
#include "socket-util.h"
89
#include "strv.h"
910
#include "user-util.h"

0 commit comments

Comments
 (0)