richardphibel / rpms / systemd

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