diff options
author | Alan Jenkins <alan.christopher.jenkins@gmail.com> | 2018-02-05 17:53:40 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-02-05 17:53:40 +0100 |
commit | fe167298681ccc0292b72a03ba82889792a1c982 (patch) | |
tree | a118985d069adfe877a69fe7aed81d50e514bc40 /src/journal/journald-kmsg.c | |
parent | hwdb: fix mute microphone button on TravelMate P645-S (#8105) (diff) | |
download | systemd-fe167298681ccc0292b72a03ba82889792a1c982.tar.xz systemd-fe167298681ccc0292b72a03ba82889792a1c982.zip |
journal: include kmsg lines from the systemd process which exec()d us (#8078)
Let the journal capture messages emitted by systemd, before it ran
exec("/usr/lib/systemd/systemd-journald"). Usually such messages will only
appear with `systemd.log_level=debug`. kmsg lines written after the exec()
will be ignored as before.
In other words, we are avoiding reading our own lines, which start
"systemd-journald[100]: " assuming we are PID 100. But now we will start
allowing ourself to read lines which start "systemd[100]: ", or any other
prefix which is not "systemd-journald[100]: ".
So this can't help you see messages when we fail to exec() journald :). But,
it makes it easier to see what the pre-exec() messages look like in
the successful case. Comparing messages like this can be useful when
debugging. Noticing weird omissions of messages, otoh, makes me anxious.
Diffstat (limited to 'src/journal/journald-kmsg.c')
-rw-r--r-- | src/journal/journald-kmsg.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c index 0fadc16fbd..27bb7a969c 100644 --- a/src/journal/journald-kmsg.c +++ b/src/journal/journald-kmsg.c @@ -98,15 +98,17 @@ void server_forward_kmsg( log_debug_errno(errno, "Failed to write to /dev/kmsg for logging: %m"); } -static bool is_us(const char *pid) { - pid_t t; +static bool is_us(const char *identifier, const char *pid) { + pid_t pid_num; - assert(pid); + if (!identifier || !pid) + return false; - if (parse_pid(pid, &t) < 0) + if (parse_pid(pid, &pid_num) < 0) return false; - return t == getpid_cached(); + return pid_num == getpid_cached() && + streq(identifier, program_invocation_short_name); } static void dev_kmsg_record(Server *s, const char *p, size_t l) { @@ -292,7 +294,7 @@ static void dev_kmsg_record(Server *s, const char *p, size_t l) { /* Avoid any messages we generated ourselves via * log_info() and friends. */ - if (pid && is_us(pid)) + if (is_us(identifier, pid)) goto finish; if (identifier) { |