diff options
author | Eric Andersen <andersen@codepoet.org> | 2004-06-22 14:07:17 +0400 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2004-06-22 14:07:17 +0400 |
commit | 36adca81f54d9479a440865acd29fc2fbcfbaf1d (patch) | |
tree | 6ad08a59a2a1cd6a8c24fd9683c5f8df32f5054c /sysklogd/klogd.c | |
parent | 78a5ddeff0352ee7a4f6a02333c07657f0b4ccc0 (diff) |
Patch from Bastian Blank:
On Sat, Jun 19, 2004 at 10:57:37PM +0200, Bastian Blank wrote:
> The following patch changes klogd to use openlog/syslog themself
> instead of calling syslog_msg which always calls the triple
> openlog/syslog/closelog.
Updated patch: get rid of syslog_msg entirely. Request from Erik Andersen.
Bastian
Diffstat (limited to 'sysklogd/klogd.c')
-rw-r--r-- | sysklogd/klogd.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/sysklogd/klogd.c b/sysklogd/klogd.c index 94da61658..9f07d6743 100644 --- a/sysklogd/klogd.c +++ b/sysklogd/klogd.c @@ -47,8 +47,8 @@ static void klogd_signal(int sig) klogctl(7, NULL, 0); klogctl(0, 0, 0); /* logMessage(0, "Kernel log daemon exiting."); */ - syslog_msg(LOG_SYSLOG, LOG_NOTICE, "Kernel log daemon exiting."); - exit(TRUE); + syslog(LOG_NOTICE, "Kernel log daemon exiting."); + exit(EXIT_SUCCESS); } static void doKlogd(const char console_log_level) __attribute__ ((noreturn)); @@ -59,6 +59,8 @@ static void doKlogd(const char console_log_level) int i, n, lastc; char *start; + openlog("kernel", 0, LOG_KERN); + /* Set up sig handlers */ signal(SIGINT, klogd_signal); signal(SIGKILL, klogd_signal); @@ -72,22 +74,17 @@ static void doKlogd(const char console_log_level) if (console_log_level) klogctl(8, NULL, console_log_level); - syslog_msg(LOG_SYSLOG, LOG_NOTICE, "klogd started: " BB_BANNER); + syslog(LOG_NOTICE, "klogd started: " BB_BANNER); while (1) { /* Use kernel syscalls */ memset(log_buffer, '\0', sizeof(log_buffer)); n = klogctl(2, log_buffer, sizeof(log_buffer)); if (n < 0) { - char message[80]; - if (errno == EINTR) continue; - snprintf(message, 79, - "klogd: Error return from sys_sycall: %d - %s.\n", errno, - strerror(errno)); - syslog_msg(LOG_SYSLOG, LOG_ERR, message); - exit(1); + syslog(LOG_ERR, "klogd: Error return from sys_sycall: %d - %s.\n", errno, strerror(errno)); + exit(EXIT_FAILURE); } /* klogctl buffer parsing modelled after code in dmesg.c */ @@ -107,7 +104,7 @@ static void doKlogd(const char console_log_level) } if (log_buffer[i] == '\n') { log_buffer[i] = '\0'; /* zero terminate this message */ - syslog_msg(LOG_KERN, priority, start); + syslog(priority, start); start = &log_buffer[i + 1]; priority = LOG_INFO; } |