summaryrefslogtreecommitdiff
path: root/src/logger.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-01-07 00:18:51 +0100
committerLennart Poettering <lennart@poettering.net>2011-01-07 00:49:35 +0100
commit2d011a7923a35d8aef49059c2e9010bf1d6a4bac (patch)
tree90e59b2cc0a50212abb8e08d71732e2e68c20850 /src/logger.c
parente83c7c0ba480c6d37d6d586b9337b1ad32ee52ca (diff)
logger: when passing on PID info, fall back to our own if originating process is already gone
Diffstat (limited to 'src/logger.c')
-rw-r--r--src/logger.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/logger.c b/src/logger.c
index 32c57f8f82..482ec41244 100644
--- a/src/logger.c
+++ b/src/logger.c
@@ -187,8 +187,28 @@ static int stream_log(Stream *s, char *p, usec_t ts) {
for (;;) {
ssize_t n;
- if ((n = sendmsg(s->server->syslog_fd, &msghdr, MSG_NOSIGNAL)) < 0)
+ if ((n = sendmsg(s->server->syslog_fd, &msghdr, MSG_NOSIGNAL)) < 0) {
+
+ if (errno == ESRCH) {
+ pid_t our_pid;
+
+ /* Hmm, maybe the process this
+ * line originates from is
+ * dead? Then let's patch in
+ * our own pid and retry,
+ * since we have nothing
+ * better */
+
+ our_pid = getpid();
+
+ if (ucred->pid != our_pid) {
+ ucred->pid = our_pid;
+ continue;
+ }
+ }
+
return -errno;
+ }
if (!s->server->syslog_is_stream ||
(size_t) n >= IOVEC_TOTAL_SIZE(iovec, ELEMENTSOF(iovec)))