naccyde / rpms / systemd

Forked from rpms/systemd a year ago
Clone
572a44
From 3bdb6f693180ae6a64af158ddf23fb1335380e48 Mon Sep 17 00:00:00 2001
572a44
From: Dan McGee <dan@archlinux.org>
572a44
Date: Sun, 8 Dec 2013 13:27:05 -0600
572a44
Subject: [PATCH] Ensure unit is journaled for short-lived or oneshot processes
572a44
572a44
In the time it takes to process incoming log messages, the process we
572a44
are logging details for may exit. This means the cgroup data is no
572a44
longer available from '/proc'. Unfortunately, the way the code was
572a44
structured before, we never log _SYSTEMD_UNIT if we don't have this
572a44
cgroup information.
572a44
572a44
Add an else if case that allows the passed in unit_id to be logged even
572a44
if we couldn't capture cgroup information. This ensures a command like
572a44
`journalctl -u run-XXX` will return all log messages from a oneshot
572a44
process.
572a44
---
572a44
 src/journal/journald-server.c | 3 +++
572a44
 1 file changed, 3 insertions(+)
572a44
572a44
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
572a44
index a0a8e9c..1fcb3d5 100644
572a44
--- a/src/journal/journald-server.c
572a44
+++ b/src/journal/journald-server.c
572a44
@@ -626,6 +626,9 @@ static void dispatch_message_real(
572a44
                         }
572a44
 
572a44
                         free(c);
572a44
+                } else if (unit_id) {
572a44
+                        x = strappenda("_SYSTEMD_UNIT=", unit_id);
572a44
+                        IOVEC_SET_STRING(iovec[n++], x);
572a44
                 }
572a44
 
572a44
 #ifdef HAVE_SELINUX