Page MenuHomeFreeBSD

D41380.id125986.diff
No OneTemporary

D41380.id125986.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
@@ -156,7 +156,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";
@@ -761,6 +760,18 @@
if (Sflag == 0)
addsock(_PATH_LOG_PRIV, NULL, S_IRUSR | S_IWUSR);
+ 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)
+ err(1, "cannot open %s", _PATH_CONSOLE);
+ (void)strlcpy(consfile.fu_fname, _PATH_CONSOLE + sizeof(_PATH_DEV) - 1,
+ sizeof(consfile.fu_fname));
+ (void)strlcpy(bootfile, getbootfile(), sizeof(bootfile));
+
pfh = pidfile_open(PidFile, 0600, &spid);
if (pfh == NULL) {
if (errno == EEXIST)
@@ -778,11 +789,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();
if (kq == -1) {
warn("failed to initialize kqueue");
@@ -1622,20 +1628,9 @@
/* 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;
- }
+ consfile.f_lasttime = *timestamp;
+ fprintlog_first(&consfile, hostname, app_name, procid,
+ msgid, structured_data, msg, flags);
return;
}
@@ -3019,7 +3014,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
Sat, Mar 1, 9:42 PM (20 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16912501
Default Alt Text
D41380.id125986.diff (2 KB)

Event Timeline