process-util: introduce procfs_file_get_field() wrapper

which combines procfs_file_alloca() and get_proc_field()
This commit is contained in:
Mike Yuan
2025-05-01 13:10:26 +09:00
committed by Yu Watanabe
parent 3589d6c01f
commit 5fd63a5a5e
+5
View 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"
@@ -33,6 +34,10 @@
(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,