|
Message-Id: <1436029084-6797-1-git-send-email-timo.teras@iki.fi> Date: Sat, 4 Jul 2015 19:58:04 +0300 From: Timo Teräs <timo.teras@....fi> To: musl@...ts.openwall.com Cc: Timo Teräs <timo.teras@....fi> Subject: [PATCH] close syslog socket on error to recreate it later if syslogd is restarted, the socket is left in unconnected state and all logging will cease --- src/misc/syslog.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/misc/syslog.c b/src/misc/syslog.c index e026f9b..c329956 100644 --- a/src/misc/syslog.c +++ b/src/misc/syslog.c @@ -107,11 +107,15 @@ static void _vsyslog(int priority, const char *message, va_list ap) if (l2 >= sizeof buf - l) l = sizeof buf - 1; else l += l2; if (buf[l-1] != '\n') buf[l++] = '\n'; - if (send(log_fd, buf, l, 0) < 0 && (log_opt & LOG_CONS)) { - fd = open("/dev/console", O_WRONLY|O_NOCTTY|O_CLOEXEC); - if (fd >= 0) { - dprintf(fd, "%.*s", l-hlen, buf+hlen); - close(fd); + if (send(log_fd, buf, l, 0) < 0) { + close(log_fd); + log_fd = -1; + if (log_opt & LOG_CONS)) { + fd = open("/dev/console", O_WRONLY|O_NOCTTY|O_CLOEXEC); + if (fd >= 0) { + dprintf(fd, "%.*s", l-hlen, buf+hlen); + close(fd); + } } } if (log_opt & LOG_PERROR) dprintf(2, "%.*s", l-hlen, buf+hlen); -- 2.4.5
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.