From: Dan McGee Date: Sun, 8 Dec 2013 19:27:05 +0000 (-0600) Subject: Ensure unit is journaled for short-lived or oneshot processes X-Git-Tag: v209~1061 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=2d43b190901902dbd98ccea77c1d1ddc9e2a9955;hp=06d461ee6f3da6650e6d023d7828455752d70b0b 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. --- diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index 01e75b662..fc8115c31 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