Page MenuHomeFreeBSD

D41380.id125735.diff
No OneTemporary

D41380.id125735.diff

diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -142,7 +142,6 @@
static const char *ConfFile = _PATH_LOGCONF;
static const char *PidFile = _PATH_LOGPID;
-static const char ctty[] = _PATH_CONSOLE;
static const char include_str[] = "include";
static const char include_ext[] = ".conf";
@@ -243,8 +242,7 @@
static void
close_filed(struct filed *f)
{
-
- if (f == NULL || f->f_file == -1)
+ if (f == NULL || f->f_file < 0)
return;
switch (f->f_type) {
@@ -669,9 +667,6 @@
} else if (Debug)
setlinebuf(stdout);
- consfile.f_type = F_CONSOLE;
- (void)strlcpy(consfile.fu_fname, ctty + sizeof(_PATH_DEV) - 1,
- sizeof(consfile.fu_fname));
(void)strlcpy(bootfile, getbootfile(), sizeof(bootfile));
kq = kqueue();
@@ -709,6 +704,17 @@
}
}
+ consfile.f_type = F_CONSOLE;
+ /*
+ * Open in non-blocking mode to avoid hangs during open
+ * and close (waiting for the port to drain).
+ */
+ consfile.f_file = open(_PATH_CONSOLE, O_WRONLY | O_NONBLOCK);
+ if (consfile.f_file < 0)
+ dprintf("can't open %s (%d)\n", _PATH_CONSOLE, errno);
+ (void)strlcpy(consfile.fu_fname, _PATH_CONSOLE + sizeof(_PATH_DEV) - 1,
+ sizeof(consfile.fu_fname));
+
init(false);
for (;;) {
switch (kevent(kq, NULL, 0, &ev, 1, needdofsync ? &ts : tsp)) {
@@ -1510,19 +1516,10 @@
/* log the message to the particular outputs */
if (!Initialized) {
- f = &consfile;
- /*
- * Open in non-blocking mode to avoid hangs during open
- * and close(waiting for the port to drain).
- */
- f->f_file = open(ctty, O_WRONLY | O_NONBLOCK, 0);
-
- if (f->f_file >= 0) {
- f->f_lasttime = *timestamp;
- fprintlog_first(f, hostname, app_name, procid, msgid,
- structured_data, msg, flags);
- close(f->f_file);
- f->f_file = -1;
+ if (consfile.f_file >= 0) {
+ consfile.f_lasttime = *timestamp;
+ fprintlog_first(&consfile, hostname, app_name, procid,
+ msgid, structured_data, msg, flags);
}
return;
}
@@ -2213,6 +2210,7 @@
if (f->f_type == F_PIPE && f->fu_pipe_pd >= 0)
close_filed(f);
}
+ close_filed(&consfile);
if (signo) {
dprintf("syslogd: exiting on signal %d\n", signo);
(void)snprintf(buf, sizeof(buf), "exiting on signal %d", signo);
@@ -2918,7 +2916,7 @@
if (syncfile)
f->f_flags |= FFLAG_SYNC;
if (isatty(f->f_file)) {
- if (strcmp(p, ctty) == 0)
+ if (strcmp(p, _PATH_CONSOLE) == 0)
f->f_type = F_CONSOLE;
else
f->f_type = F_TTY;

File Metadata

Mime Type
text/plain
Expires
Fri, Oct 2, 5:41 PM (20 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40092395
Default Alt Text
D41380.id125735.diff (2 KB)

Event Timeline