From: Lennart Poettering Date: Thu, 31 Oct 2024 14:11:39 +0000 (+0100) Subject: coredump: acquire some process fields via pidref X-Git-Tag: v257-rc1~68^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1f485bc7356c41caff4fb6fb6b9fb400114d8584;p=thirdparty%2Fsystemd.git coredump: acquire some process fields via pidref Use pidref to acquire some fields. This just makes use of the pidref helpers we already have. We acquire a lot of other data via classic pids still, but for that we first have to write race-free pidref getters, hence leave that for another time. --- diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c index fdcb97b803b..6d556a7a1f6 100644 --- a/src/coredump/coredump.c +++ b/src/coredump/coredump.c @@ -1385,7 +1385,7 @@ static int gather_pid_metadata_from_procfs(struct iovec_wrapper *iovw, Context * pid = context->pidref.pid; /* The following is mandatory */ - r = pid_get_comm(pid, &t); + r = pidref_get_comm(&context->pidref, &t); if (r < 0) return log_error_errno(r, "Failed to get COMM: %m"); @@ -1400,7 +1400,7 @@ static int gather_pid_metadata_from_procfs(struct iovec_wrapper *iovw, Context * if (r < 0) log_warning_errno(r, "Failed to get EXE, ignoring: %m"); - if (cg_pid_get_unit(pid, &t) >= 0) + if (cg_pidref_get_unit(&context->pidref, &t) >= 0) (void) iovw_put_string_field_free(iovw, "COREDUMP_UNIT=", t); if (cg_pid_get_user_unit(pid, &t) >= 0) @@ -1418,7 +1418,7 @@ static int gather_pid_metadata_from_procfs(struct iovec_wrapper *iovw, Context * if (sd_pid_get_slice(pid, &t) >= 0) (void) iovw_put_string_field_free(iovw, "COREDUMP_SLICE=", t); - if (pid_get_cmdline(pid, SIZE_MAX, PROCESS_CMDLINE_QUOTE_POSIX, &t) >= 0) + if (pidref_get_cmdline(&context->pidref, SIZE_MAX, PROCESS_CMDLINE_QUOTE_POSIX, &t) >= 0) (void) iovw_put_string_field_free(iovw, "COREDUMP_CMDLINE=", t); if (cg_pid_get_path_shifted(pid, NULL, &t) >= 0)