]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
coredump: acquire some process fields via pidref
authorLennart Poettering <lennart@poettering.net>
Thu, 31 Oct 2024 14:11:39 +0000 (15:11 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 31 Oct 2024 22:08:11 +0000 (23:08 +0100)
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.

src/coredump/coredump.c

index fdcb97b803b6b767e972d032c6dc55c37d4fc501..6d556a7a1f65b2443d5ad4a9e5a657604750b00c 100644 (file)
@@ -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)