From nobody Wed Oct 09 12:18:02 2024 X-Original-To: dev-commits-src-all@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 4XNsNn3RL8z5YSVl; Wed, 09 Oct 2024 12:18:17 +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 4XNsNm2wZ5z4Wf4; Wed, 9 Oct 2024 12:18:15 +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 499CI2nK006004; Wed, 9 Oct 2024 15:18:05 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 499CI2nK006004 Received: (from kostik@localhost) by tom.home (8.18.1/8.18.1/Submit) id 499CI29L006003; Wed, 9 Oct 2024 15:18:02 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 9 Oct 2024 15:18:02 +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> <86iku2v3o2.fsf@ltc.des.dev> List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <86iku2v3o2.fsf@ltc.des.dev> 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: 4XNsNm2wZ5z4Wf4 X-Spamd-Bar: ---- On Tue, Oct 08, 2024 at 08:40:45PM +0200, Dag-Erling Smørgrav wrote: > Konstantin Belousov writes: > > Dag-Erling Smørgrav writes: > > > + if (fflush(stdout) != 0) > > > + err(1, "stdout"); > > Why is this check needed? > > POSIX requires it. Could you please point me to the requirement? > > > Or, put it differently, why is it needed for env(1) but not any other > > program that writes to stdout? > > You mean like these? > > % git -P grep -l 'err\(1, "stdout"\)' > bin/cat/cat.c > bin/date/date.c > sbin/md5/md5.c > usr.bin/asa/asa.c > usr.bin/comm/comm.c > usr.bin/ctags/ctags.c > usr.bin/du/du.c > usr.bin/env/env.c > usr.bin/head/head.c > usr.bin/join/join.c > usr.bin/lastcomm/lastcomm.c > usr.bin/locate/code/locate.code.c > usr.bin/ncal/ncal.c > usr.bin/sed/main.c > usr.bin/tail/misc.c > usr.bin/tsort/tsort.c > usr.bin/w/w.c > usr.bin/yes/yes.c This is a mixed bag. Some programs do this 'err(1, "stdout")' call due to libxo error, which is not exactly due to stdout error state. Other do check individual fwrite/fputc operations. > > or these? > > https://reviews.freebsd.org/D41390 > https://reviews.freebsd.org/D41408 > https://reviews.freebsd.org/D41413 > https://reviews.freebsd.org/D41414 > https://reviews.freebsd.org/D41417 > https://reviews.freebsd.org/D41418 > https://reviews.freebsd.org/D41422 > https://reviews.freebsd.org/D41423 > https://reviews.freebsd.org/D41424 > https://reviews.freebsd.org/D41427 > https://reviews.freebsd.org/D41428 > https://reviews.freebsd.org/D41432 Again, it is mixed stuff, sometimes it is libxo etc.