Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/syslogd don't call isatty() to the fd before openin...



details:   https://anonhg.NetBSD.org/src/rev/46a8a0d75e5f
branches:  trunk
changeset: 779781:46a8a0d75e5f
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Jun 18 19:17:42 2012 +0000

description:
don't call isatty() to the fd before opening it.

diffstat:

 usr.sbin/syslogd/syslogd.c |  24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diffs (57 lines):

diff -r b42f5b5ef5d1 -r 46a8a0d75e5f usr.sbin/syslogd/syslogd.c
--- a/usr.sbin/syslogd/syslogd.c        Mon Jun 18 15:53:22 2012 +0000
+++ b/usr.sbin/syslogd/syslogd.c        Mon Jun 18 19:17:42 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: syslogd.c,v 1.109 2012/06/06 00:33:45 christos Exp $   */
+/*     $NetBSD: syslogd.c,v 1.110 2012/06/18 19:17:42 christos Exp $   */
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)syslogd.c  8.3 (Berkeley) 4/4/94";
 #else
-__RCSID("$NetBSD: syslogd.c,v 1.109 2012/06/06 00:33:45 christos Exp $");
+__RCSID("$NetBSD: syslogd.c,v 1.110 2012/06/18 19:17:42 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -3608,7 +3608,7 @@
     const char *host)
 {
        struct addrinfo hints, *res;
-       int    error, i, pri, syncfile, flags;
+       int    error, i, pri, syncfile;
        const char   *p, *q;
        char *bp;
        char   buf[MAXLINE];
@@ -3822,20 +3822,20 @@
                        f->f_flags |= FFLAG_SIGN;
 #endif /* !DISABLE_SIGN */
                (void)strlcpy(f->f_un.f_fname, p, sizeof(f->f_un.f_fname));
+               if ((f->f_file = open(p, O_WRONLY|O_APPEND, 0)) < 0) {
+                       f->f_type = F_UNUSED;
+                       logerror("%s", p);
+                       break;
+               }
                if (isatty(f->f_file)) {
                        f->f_type = F_TTY;
                        if (strcmp(p, ctty) == 0)
                                f->f_type = F_CONSOLE;
-                       flags = O_NDELAY;
-               } else {
+                       if (fcntl(f->f_file, F_SETFL, O_NONBLOCK) == -1)
+                               logerror("Warning: cannot change tty fd for"
+                                   " `%s' to non-blocking.", p);
+               } else
                        f->f_type = F_FILE;
-                       flags = 0;
-               }
-               if ((f->f_file = open(p, O_WRONLY|O_APPEND|flags, 0)) < 0) {
-                       f->f_type = F_UNUSED;
-                       logerror("%s", p);
-                       break;
-               }
                if (syncfile)
                        f->f_flags |= FFLAG_SYNC;
                break;



Home | Main Index | Thread Index | Old Index