logger: when passing on PID info, fall back to our own if originating process is already gone

This commit is contained in:
Lennart Poettering 2011-01-07 00:18:51 +01:00
parent e83c7c0ba4
commit 2d011a7923
2 changed files with 23 additions and 1 deletions

2
TODO
View File

@ -1,3 +1,5 @@
* when launching pager, take number of columns first
* support remote/ssh systemctl/systemadm, and local privileged access
* finish syslog socket stuff

View File

@ -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)))