From 62bca2c657bf95fd1f69935eef09915afa5c69d9 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 21 Jun 2012 16:40:47 -0400 Subject: journal: set the _SYSTEMD_UNIT field for messages from terminated processes As described in https://bugs.freedesktop.org/show_bug.cgi?id=50184 the journal currently doesn't set fields such as _SYSTEMD_UNIT properly for messages coming from processes that have already terminated. This means among other things that "systemctl status" may not show some of the output of services that wrote messages just before they exited. This patch fixes this by having processes that log to the journal write their unit identifier to journald when the connection to /run/systemd/journal/stdout is opened. Journald stores the unit ID and uses it to fill in _SYSTEMD_UNIT when it cannot be obtained normally (i.e. from the cgroup). To prevent impersonating another unit, this information is only used when the caller is root. This doesn't fix the general problem of getting metadata about messages from terminated processes (which requires some kernel support), but it allows "systemctl status" and similar queries to do the Right Thing for units that log via stdout/stderr. --- src/core/swap.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/core/swap.c') diff --git a/src/core/swap.c b/src/core/swap.c index e7ed1b88d7..f3c7fa3076 100644 --- a/src/core/swap.c +++ b/src/core/swap.c @@ -590,6 +590,7 @@ static int swap_spawn(Swap *s, ExecCommand *c, pid_t *_pid) { UNIT(s)->cgroup_bondings, UNIT(s)->cgroup_attributes, NULL, + UNIT(s)->id, NULL, &pid)) < 0) goto fail; -- cgit v1.2.3-54-g00ecf