From nobody Tue Oct 08 17:41:20 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XNNcM3S9Xz5Xhhw; Tue, 08 Oct 2024 17:41:39 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4XNNcL1GxRz4BvC; Tue, 8 Oct 2024 17:41:38 +0000 (UTC) (envelope-from kostikbel@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: from tom.home (kib@localhost [127.0.0.1] (may be forged)) by kib.kiev.ua (8.18.1/8.18.1) with ESMTP id 498HfKYs072042; Tue, 8 Oct 2024 20:41:23 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 498HfKYs072042 Received: (from kostik@localhost) by tom.home (8.18.1/8.18.1/Submit) id 498HfKJE072041; Tue, 8 Oct 2024 20:41:20 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 8 Oct 2024 20:41:20 +0300 From: Konstantin Belousov To: Dag-Erling =?utf-8?B?U23DuHJncmF2?= 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: References: <202410081702.498H2KIP072012@gitrepo.freebsd.org> List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <202410081702.498H2KIP072012@gitrepo.freebsd.org> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on tom.home X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US] X-Rspamd-Queue-Id: 4XNNcL1GxRz4BvC X-Spamd-Bar: ---- 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 > AuthorDate: 2024-10-08 17:01:46 +0000 > Commit: Dag-Erling Smørgrav > 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?