]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
process-util: introduce procfs_file_get_field() wrapper
authorMike Yuan <me@yhndnzj.com>
Wed, 30 Apr 2025 17:34:23 +0000 (19:34 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 1 May 2025 04:10:26 +0000 (13:10 +0900)
which combines procfs_file_alloca() and get_proc_field()

src/basic/process-util.h

index df6daf1839da9120bc0d3a12bd163850257d100e..9ae36cf60901e847e458d4a0563cd97b13956b2a 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "alloc-util.h"
 #include "assert-util.h"
+#include "fileio.h"
 #include "format-util.h"
 #include "macro.h"
 #include "pidref.h"
                 (const char*) _r_;                                      \
         })
 
+static inline int procfs_file_get_field(pid_t pid, const char *name, const char *key, char **ret) {
+        return get_proc_field(procfs_file_alloca(pid, name), key, ret);
+}
+
 typedef enum ProcessCmdlineFlags {
         PROCESS_CMDLINE_COMM_FALLBACK = 1 << 0,
         PROCESS_CMDLINE_USE_LOCALE    = 1 << 1,