systemd/0154-Ensure-unit-is-journaled-for-short-lived-or-oneshot-.patch

34 lines
1.3 KiB
Diff
Raw Normal View History

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