Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 Oct 2024 20:41:20 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Dag-Erling =?utf-8?B?U23DuHJncmF2?= <des@freebsd.org>
Cc:        src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org
Subject:   Re: git: c2d93a803ace - main - env: Check the status of stdout.
Message-ID:  <ZwVuwK9Lry_6JDay@kib.kiev.ua>
In-Reply-To: <202410081702.498H2KIP072012@gitrepo.freebsd.org>

index | next in thread | previous in thread | raw e-mail

On Tue, Oct 08, 2024 at 05:02:20PM +0000, Dag-Erling Smørgrav wrote:
> The branch main has been updated by des:
> 
> URL: https://cgit.FreeBSD.org/src/commit/?id=c2d93a803acef634bd0eede6673aeea59e90c277
> 
> commit c2d93a803acef634bd0eede6673aeea59e90c277
> Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
> AuthorDate: 2024-10-08 17:01:46 +0000
> Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
> CommitDate: 2024-10-08 17:01:46 +0000
> 
>     env: Check the status of stdout.
>     
>     MFC after:      3 days
>     Sponsored by:   Klara, Inc.
>     Reviewed by:    markj
>     Differential Revision:  https://reviews.freebsd.org/D47009
> ---
>  usr.bin/env/env.c             |  2 ++
>  usr.bin/env/tests/env_test.sh | 17 +++++++++++++++++
>  2 files changed, 19 insertions(+)
> 
> diff --git a/usr.bin/env/env.c b/usr.bin/env/env.c
> index bb83baee114f..10e333602ee8 100644
> --- a/usr.bin/env/env.c
> +++ b/usr.bin/env/env.c
> @@ -214,6 +214,8 @@ main(int argc, char **argv)
>  	}
>  	for (ep = environ; *ep; ep++)
>  		(void)printf("%s%c", *ep, term);
> +	if (fflush(stdout) != 0)
> +		err(1, "stdout");
>  	exit(0);
Why is this check needed?

Or, put it differently, why is it needed for env(1) but not any other
program that writes to stdout?


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ZwVuwK9Lry_6JDay>