Date: Wed, 17 Mar 2010 17:33:10 +0100 From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no> To: Bruce Evans <brde@optusnet.com.au> Cc: svn-src-head@FreeBSD.org, Poul-Henning Kamp <phk@phk.freebsd.dk>, src-committers@FreeBSD.org, svn-src-all@FreeBSD.org Subject: Re: svn commit: r205165 - head/lib/libc/gen Message-ID: <86ljdq6h89.fsf@ds4.des.no> In-Reply-To: <20100317041500.V26092@delplex.bde.org> (Bruce Evans's message of "Wed, 17 Mar 2010 04:55:01 %2B1100 (EST)") References: <44640.1268676905@critter.freebsd.dk> <20100317041500.V26092@delplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Bruce Evans <brde@optusnet.com.au> 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 <errno.h> #include <fcntl.h> #include <paths.h> +#include <stdio.h> #include <stdlib.h> #include <signal.h> #include <unistd.h> @@ -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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86ljdq6h89.fsf>