]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic: Remove circular dependency between process-util.h and pidref.h
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sat, 12 Apr 2025 17:45:49 +0000 (19:45 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 18 Apr 2025 12:19:16 +0000 (14:19 +0200)
14 files changed:
src/basic/capability-util.c
src/basic/pidref.h
src/libsystemd/sd-bus/bus-objects.c
src/libsystemd/sd-bus/bus-slot.c
src/login/logind-session-dbus.c
src/login/logind-utmp.c
src/login/logind-varlink.c
src/machine/image-varlink.c
src/ptyfwd/ptyfwd-tool.c
src/shared/notify-recv.c
src/shared/pretty-print.h
src/test/test-display-quota.c
src/udev/udev-watch.c
src/varlinkctl/varlinkctl.c

index 0b544ea64a5dbe9c34412ceab449270f537d8462..0aaf8c3807bd58577654e0a2ead9ff784f86ab00 100644 (file)
@@ -20,6 +20,7 @@
 #include "macro.h"
 #include "parse-util.h"
 #include "pidref.h"
+#include "process-util.h"
 #include "stat-util.h"
 #include "user-util.h"
 
index b71c3bd9d0c6d5cf003c525f3bdeb17e482478f0..064b9d851a95367cf48918a76a8344b5f43b2742 100644 (file)
@@ -1,10 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-typedef struct PidRef PidRef;
-
 #include "macro.h"
-#include "process-util.h"
+#include "memory-util.h"
 
 /* An embeddable structure carrying a reference to a process. Supposed to be used when tracking processes
  * 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;
  *    process. Moreover, most operations will fail with -EREMOTE. Only PidRef structures that are not marked
  *    *unset* can be marked *remote*.
  */
-struct PidRef {
-        pid_t pid;      /* > 0 if the PidRef is set, otherwise set to PID_AUTOMATIC if automatic mode is
-                         * desired, or 0 otherwise. */
+typedef struct PidRef {
+        pid_t pid;      /* > 0 if the PidRef is set, otherwise set to INT_MIN (PID_AUTOMATIC) if automatic
+                         * mode is desired, or 0 otherwise. */
         int fd;         /* only valid if pidfd are available in the kernel, and we manage to get an fd. If we
                          * know that the PID is not from the local machine we set this to -EREMOTE, otherwise
                          * we use -EBADF as indicator the fd is invalid. */
         uint64_t fd_id; /* the inode number of pidfd. only useful in kernel 6.9+ where pidfds live in
                            their own pidfs and each process comes with a unique inode number */
-};
+} PidRef;
 
 #define PIDREF_NULL (PidRef) { .fd = -EBADF }
 
 /* A special pidref value that we are using when a PID shall be automatically acquired from some surrounding
  * context, for example connection peer. Much like PIDREF_NULL it will be considered unset by
  * pidref_is_set(). */
-#define PIDREF_AUTOMATIC (const PidRef) { .pid = PID_AUTOMATIC, .fd = -EBADF }
+#define PIDREF_AUTOMATIC (const PidRef) { .pid = (pid_t) INT_MIN, .fd = -EBADF }
 
 /* Turns a pid_t into a PidRef structure on-the-fly *without* acquiring a pidfd for it. (As opposed to
  * pidref_set_pid() which does so *with* acquiring one, see below) */
index 2e3c4e0d6898568683525e2d88c7c78d7e9329a7..37f9495138f8c6def073f1102b3735688163e809 100644 (file)
@@ -11,6 +11,7 @@
 #include "bus-slot.h"
 #include "bus-type.h"
 #include "log.h"
+#include "set.h"
 #include "string-util.h"
 #include "strv.h"
 
index 25272dbc0f782d0cbbd979ee4809ebe0f7e2a1e9..ed9da9663839f835d97e1258d2f1287be3bc5ef8 100644 (file)
@@ -7,6 +7,7 @@
 #include "bus-objects.h"
 #include "bus-slot.h"
 #include "log.h"
+#include "set.h"
 #include "string-util.h"
 
 sd_bus_slot *bus_slot_allocate(
index 5e374ae91e880c98a55605ba49b91c00588fb471..3a00a700c93368cefea9a9fd5f880f3e135c64d6 100644 (file)
@@ -10,6 +10,7 @@
 #include "bus-util.h"
 #include "devnum-util.h"
 #include "fd-util.h"
+#include "format-util.h"
 #include "logind-brightness.h"
 #include "logind-dbus.h"
 #include "logind-polkit.h"
index 9b6f4adcf035eb8a3541a0c6b047925e13421ca6..47a293914baeeadb133d197be811d32b378a77c7 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "logind-utmp.h"
 #include "path-util.h"
+#include "process-util.h"
 #include "utmp-wtmp.h"
 
 int manager_read_utmp(Manager *m) {
index 83f0c55531cc6c98944a9937eb63e091babedb53..d812d81b20086be537977bc611b2829086ffab88 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "cgroup-util.h"
 #include "fd-util.h"
+#include "format-util.h"
 #include "json-util.h"
 #include "logind.h"
 #include "logind-dbus.h"
index eb0fc12dc6bf3a66217c805bab1da01bf0b644b8..fc05edf8e1498c73f61100031f07ddc39077d682 100644 (file)
@@ -13,6 +13,7 @@
 #include "json-util.h"
 #include "machine.h"
 #include "machine-pool.h"
+#include "process-util.h"
 #include "string-util.h"
 
 typedef struct ImageUpdateParameters {
index 26bb295b3fbcab4f92c013600915d1eb652bc918..16a49ccdc1bab5ea25dc13abb0747209e35df71f 100644 (file)
@@ -10,6 +10,7 @@
 #include "log.h"
 #include "main-func.h"
 #include "pretty-print.h"
+#include "process-util.h"
 #include "ptyfwd.h"
 #include "strv.h"
 
index ac790da2a8c35afbf2a0b0fa5934979f38f07cc5..0e64bdde04b4e76456e97a81dca171b7e2c96422 100644 (file)
@@ -4,6 +4,7 @@
 #include "fd-util.h"
 #include "log.h"
 #include "notify-recv.h"
+#include "process-util.h"
 #include "socket-util.h"
 #include "strv.h"
 #include "user-util.h"
index 16966c3ab8c9f9a97fee4099e86689757533e5c1..6f44955076530ddc45658e2bb6f0418b7880706d 100644 (file)
@@ -1,6 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
+#include <string.h>
+
 #include "ansi-color.h"
 #include "assert-util.h"
 #include "glyph-util.h"
index e3b67526a30b5e755ac5e56b0bd8ababbb7fd342..68ecfc8d0139902916ac6b9cc8fff32356870df6 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "bitfield.h"
 #include "fd-util.h"
+#include "format-util.h"
 #include "log.h"
 #include "main-func.h"
 #include "missing_syscall.h"
index 506c3e0835b7f06c628a205108e57f51fe6135a1..2d3127eee998595189f9376a689c8351141f1806 100644 (file)
@@ -15,7 +15,9 @@
 #include "inotify-util.h"
 #include "mkdir.h"
 #include "parse-util.h"
+#include "process-util.h"
 #include "rm-rf.h"
+#include "set.h"
 #include "stdio-util.h"
 #include "string-util.h"
 #include "udev-manager.h"
index 3bcb34b642bf9faf3a1b57932196a487fb4d74b5..7b2ff301aa9ff7f076e51cb53b3ad0f0fe1a5a2e 100644 (file)
@@ -17,6 +17,7 @@
 #include "parse-argument.h"
 #include "path-util.h"
 #include "pretty-print.h"
+#include "process-util.h"
 #include "terminal-util.h"
 #include "varlink-idl-util.h"
 #include "varlink-util.h"