+static int print_info(FILE *file, sd_journal *j, bool need_space) {
+ _cleanup_free_ char
+ *pid = NULL, *uid = NULL, *gid = NULL,
+ *sgnl = NULL, *exe = NULL, *comm = NULL, *cmdline = NULL,
+ *unit = NULL, *user_unit = NULL, *session = NULL,
+ *boot_id = NULL, *machine_id = NULL, *hostname = NULL, *coredump = NULL;
+ const void *d;
+ size_t l;
+
+ assert(file);
+ assert(j);
+
+ SD_JOURNAL_FOREACH_DATA(j, d, l) {
+ retrieve(d, l, "COREDUMP_PID", &pid);
+ retrieve(d, l, "COREDUMP_UID", &uid);
+ retrieve(d, l, "COREDUMP_GID", &gid);
+ retrieve(d, l, "COREDUMP_SIGNAL", &sgnl);
+ retrieve(d, l, "COREDUMP_EXE", &exe);
+ retrieve(d, l, "COREDUMP_COMM", &comm);
+ retrieve(d, l, "COREDUMP_CMDLINE", &cmdline);
+ retrieve(d, l, "COREDUMP_UNIT", &unit);
+ retrieve(d, l, "COREDUMP_USER_UNIT", &user_unit);
+ retrieve(d, l, "COREDUMP_SESSION", &session);
+ retrieve(d, l, "_BOOT_ID", &boot_id);
+ retrieve(d, l, "_MACHINE_ID", &machine_id);
+ retrieve(d, l, "_HOSTNAME", &hostname);
+ }
+
+ if (need_space)
+ fputs("\n", file);
+
+ fprintf(file,
+ " PID: %s\n"
+ " UID: %s\n"
+ " GID: %s\n",
+ strna(pid),
+ strna(uid),
+ strna(gid));
+
+ if (sgnl) {
+ int sig;
+
+ if (safe_atoi(sgnl, &sig) >= 0)
+ fprintf(file, " Signal: %s (%s)\n", sgnl, signal_to_string(sig));
+ else
+ fprintf(file, " Signal: %s\n", sgnl);
+ }
+
+ if (exe)
+ fprintf(file, " Executable: %s\n", exe);
+ if (comm)
+ fprintf(file, " Comm: %s\n", comm);
+ if (cmdline)
+ fprintf(file, " Command Line: %s\n", cmdline);
+ if (unit)
+ fprintf(file, " Unit: %s\n", unit);
+ if (user_unit)
+ fprintf(file, " User Unit: %s\n", unit);
+ if (session)
+ fprintf(file, " Session: %s\n", session);
+ if (boot_id)
+ fprintf(file, " Boot ID: %s\n", boot_id);
+ if (machine_id)
+ fprintf(file, " Machine ID: %s\n", machine_id);
+ if (hostname)
+ fprintf(file, " Hostname: %s\n", hostname);
+
+ if (make_coredump_path(j, &coredump) >= 0)
+ if (access(coredump, F_OK) >= 0)
+ fprintf(file, " Coredump: %s\n", coredump);
+
+ return 0;
+}
+