Date: Tue, 25 May 2004 23:36:54 +0200 (CEST) From: Martin Blapp <mb@imp.ch> To: current@freebsd.org Subject: syslogd(8): timed out waiting for child Message-ID: <20040525233637.C7820@cvs.imp.ch>
next in thread | raw e-mail | index | archive | help
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 '*':
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040525233637.C7820>