From owner-svn-src-head@FreeBSD.ORG Wed Mar 17 16:33:11 2010 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 91E771065672; Wed, 17 Mar 2010 16:33:11 +0000 (UTC) (envelope-from des@des.no) Received: from smtp.des.no (smtp.des.no [194.63.250.102]) by mx1.freebsd.org (Postfix) with ESMTP id 525D08FC08; Wed, 17 Mar 2010 16:33:11 +0000 (UTC) Received: from ds4.des.no (des.no [84.49.246.2]) by smtp.des.no (Postfix) with ESMTP id 5FD3F1FFC22; Wed, 17 Mar 2010 16:33:10 +0000 (UTC) Received: by ds4.des.no (Postfix, from userid 1001) id 3DA7A844F2; Wed, 17 Mar 2010 17:33:10 +0100 (CET) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: Bruce Evans References: <44640.1268676905@critter.freebsd.dk> <20100317041500.V26092@delplex.bde.org> Date: Wed, 17 Mar 2010 17:33:10 +0100 In-Reply-To: <20100317041500.V26092@delplex.bde.org> (Bruce Evans's message of "Wed, 17 Mar 2010 04:55:01 +1100 (EST)") Message-ID: <86ljdq6h89.fsf@ds4.des.no> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.95 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: svn-src-head@FreeBSD.org, Poul-Henning Kamp , src-committers@FreeBSD.org, svn-src-all@FreeBSD.org Subject: Re: svn commit: r205165 - head/lib/libc/gen X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Mar 2010 16:33:11 -0000 Bruce Evans writes: > Even if the child causes the flush, the content of stdout and stderr > is not flushed normally since it is redirected to /dev/null. Unflushed > input in stdin is handled more brokenly: although stdin is redirected > to /dev/null, input on it can still be read via stdin's buffer. > Inheriting unflushed input on other streams is a feature (unless these > streams are open on fd's 0-2; then these streams will have the same > corruption as std* streams open on their normal fd's 0-2). how about Index: gen/daemon.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gen/daemon.c (revision 204870) +++ gen/daemon.c (working copy) @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -81,6 +82,9 @@ (void)chdir("/"); =20 if (!noclose && (fd =3D _open(_PATH_DEVNULL, O_RDWR, 0)) !=3D -1) { + fpurge(stdin); + fflush(stdout); + fflush(stderr); (void)_dup2(fd, STDIN_FILENO); (void)_dup2(fd, STDOUT_FILENO); (void)_dup2(fd, STDERR_FILENO); ? DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no