From owner-freebsd-hackers@FreeBSD.ORG Fri Oct 31 17:14:47 2008 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F0ABA10656DF; Fri, 31 Oct 2008 17:14:47 +0000 (UTC) (envelope-from thierry.herbelot@free.fr) Received: from postfix1-g20.free.fr (postfix1-g20.free.fr [212.27.60.42]) by mx1.freebsd.org (Postfix) with ESMTP id 8425F8FC16; Fri, 31 Oct 2008 17:14:47 +0000 (UTC) (envelope-from thierry.herbelot@free.fr) Received: from smtp3-g19.free.fr (smtp3-g19.free.fr [212.27.42.29]) by postfix1-g20.free.fr (Postfix) with ESMTP id 90C272D4BDF3; Fri, 31 Oct 2008 17:46:34 +0100 (CET) Received: from smtp3-g19.free.fr (localhost.localdomain [127.0.0.1]) by smtp3-g19.free.fr (Postfix) with ESMTP id 8755817B58B; Fri, 31 Oct 2008 17:46:32 +0100 (CET) Received: from mail.herbelot.nom (bne75-4-82-227-159-103.fbx.proxad.net [82.227.159.103]) by smtp3-g19.free.fr (Postfix) with ESMTP id 488FE17B546; Fri, 31 Oct 2008 17:46:32 +0100 (CET) Received: from diversion.herbelot.nom (diversion.herbelot.nom [192.168.2.6]) by mail.herbelot.nom (8.14.1/8.14.1) with ESMTP id m9VGkUjD019620; Fri, 31 Oct 2008 17:46:31 +0100 (CET) From: Thierry Herbelot To: hackers@freebsd.org Date: Fri, 31 Oct 2008 17:46:23 +0100 User-Agent: KMail/1.9.10 X-Warning: Windows can lose your files X-Op-Sys: Le FriBi de la mort qui tue X-Org: TfH&Co X-MailScanner: Found to be clean MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200810311746.23743.thierry.herbelot@free.fr> X-Mailman-Approved-At: Fri, 31 Oct 2008 17:27:52 +0000 Cc: current ML Subject: strange behaviour with /sbin/init and serial console X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: thierry.herbelot@free.fr List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Oct 2008 17:14:48 -0000 Hello, with the following patch on /sbin/init, I have two different behaviours depending on the console type (on a i386/32 PC) : - on a video console, I see the expected two messages, - on a serial console, the messages are not displayed (init silently finishes its job and gets to start /etc/rc and everything) I assume that the writev system call is implemented in src/sys/kern/tty_cons.c::cnwrite(), but I could not parse the code to find an explanation. any taker ? TfH PS : this is initially for a RELENG_6 machine, but the code is quite similar under RELENG_7 or Current --- usr/src/sbin/init/init.c.ori 2008-10-31 14:20:48.294794898 +0100 +++ usr/src/sbin/init/init.c 2008-10-31 14:12:16.168062031 +0100 @@ -44,6 +44,8 @@ "$FreeBSD: src/sbin/init/init.c,v 1.60.2.2 2006/07/08 15:34:27 kib Exp $"; #endif /* not lint */ +#include + #include #include #include @@ -239,6 +241,23 @@ */ openlog("init", LOG_CONS|LOG_ODELAY, LOG_AUTH); + warning("warning after openlog"); +{ +int fd; + if ((fd = open("/dev/console", O_WRONLY|O_NONBLOCK, 0)) >= 0) { + struct iovec iov[2]; + struct iovec *v = iov; + + v->iov_base = (void *)"iov direct write test"; + v->iov_len = 21; + ++v; + v->iov_base = (void *)"\r\n"; + v->iov_len = 2; + (void)writev(fd, iov, 2); + (void)close(fd); + } + +} /* * Create an initial session. */