From owner-freebsd-current@FreeBSD.ORG Tue May 25 14:40:24 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 72DAA16A4CE for ; Tue, 25 May 2004 14:40:24 -0700 (PDT) Received: from mail.imp.ch (ns1.imp.ch [157.161.1.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id C1A4B43D41 for ; Tue, 25 May 2004 14:40:23 -0700 (PDT) (envelope-from mb@imp.ch) Received: from cvs.imp.ch (cvs.imp.ch [157.161.4.9]) by mail.imp.ch (8.12.9p2/8.12.3) with ESMTP id i4PLasbK077720 for ; Tue, 25 May 2004 23:36:55 +0200 (CEST) (envelope-from Martin.Blapp@imp.ch) Date: Tue, 25 May 2004 23:36:54 +0200 (CEST) From: Martin Blapp To: current@freebsd.org Message-ID: <20040525233637.C7820@cvs.imp.ch> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: syslogd(8): timed out waiting for child X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 May 2004 21:40:24 -0000 And even more, each time after kill -HUP, syslogd has been blocked for ever. After a while I found the the problem: a locked locked terminal ... After I've removed the lock, kill -HUP was possible again without any problems anymore. It looks like we missed a OpenBSD patch. The OpenBSD syslogd has now privseparation. Anybody execpt me has some interest int his area ? Martin Revision 1.43 / (download) - annotate - [select for diffs] , Fri Aug 3 20:24:16 2001 UTC (2 years, 9 months ago) by millert Branch: MAIN CVS Tags: OPENBSD_3_0_BASE, OPENBSD_3_0 Changes since 1.42: +26 -11 lines Diff to previous 1.42 (colored) Open files with O_NONBLOCK but turn off non-blocking mode for non-ttys. If write(2) returns EAGAIN just ignore the error and move on. This prevents a locked terminal from causing syslogd grief. If we ever want to support logging to a fifo this will probably have to be revisited. diff -u -r1.42 -r1.43 --- src/usr.sbin/syslogd/syslogd.c 2001/08/03 19:09:26 1.42 +++ src/usr.sbin/syslogd/syslogd.c 2001/08/03 20:24:16 1.43 @@ -1,4 +1,4 @@ -/* $OpenBSD: syslogd.c,v 1.42 2001/08/03 19:09:26 deraadt Exp $ */ +/* $OpenBSD: syslogd.c,v 1.43 2001/08/03 20:24:16 millert Exp $ */ /* * Copyright (c) 1983, 1988, 1993, 1994 @@ -43,7 +43,7 @@ #if 0 static char sccsid[] = "@(#)syslogd.c 8.3 (Berkeley) 4/4/94"; #else -static char rcsid[] = "$OpenBSD: syslogd.c,v 1.42 2001/08/03 19:09:26 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: syslogd.c,v 1.43 2001/08/03 20:24:16 millert Exp $"; #endif #endif /* not lint */ @@ -589,7 +589,7 @@ /* log the message to the particular outputs */ if (!Initialized) { f = &consfile; - f->f_file = open(ctty, O_WRONLY, 0); + f->f_file = open(ctty, O_WRONLY|O_NONBLOCK, 0); if (f->f_file >= 0) { fprintlog(f, flags, msg); @@ -758,9 +758,16 @@ /* * Check for errors on TTY's due to loss of tty */ - if ((e == EIO || e == EBADF) && f->f_type != F_FILE) { + if (e == EAGAIN) { + /* + * Silently drop messages on blocked write. + * This can happen when logging to a locked tty. + */ + break; + } else if ((e == EIO || e == EBADF) && + f->f_type != F_FILE) { f->f_file = open(f->f_un.f_fname, - O_WRONLY|O_APPEND, 0); + O_WRONLY|O_APPEND|O_NONBLOCK, 0); if (f->f_file < 0) { f->f_type = F_UNUSED; logerror(f->f_un.f_fname); @@ -1213,17 +1220,25 @@ case '/': (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_file = open(p, O_WRONLY|O_APPEND|O_NONBLOCK, 0); + if (f->f_file < 0) { f->f_type = F_UNUSED; logerror(p); break; } - if (isatty(f->f_file)) - f->f_type = F_TTY; - else + if (isatty(f->f_file)) { + if (strcmp(p, ctty) == 0) + f->f_type = F_CONSOLE; + else + f->f_type = F_TTY; + } else { f->f_type = F_FILE; - if (strcmp(p, ctty) == 0) - f->f_type = F_CONSOLE; + /* Clear O_NONBLOCK flag on f->f_file */ + if ((i = fcntl(f->f_file, F_GETFL, 0)) != -1) { + i &= ~O_NONBLOCK; + fcntl(f->f_file, F_SETFL, i); + } + } break; case '*':