Date: Wed, 9 Oct 2024 15:18:02 +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: <ZwZ0erARk2ZKAeBv@kib.kiev.ua> In-Reply-To: <86iku2v3o2.fsf@ltc.des.dev> References: <202410081702.498H2KIP072012@gitrepo.freebsd.org> <ZwVuwK9Lry_6JDay@kib.kiev.ua> <86iku2v3o2.fsf@ltc.des.dev>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Oct 08, 2024 at 08:40:45PM +0200, Dag-Erling Smørgrav wrote: > Konstantin Belousov <kostikbel@gmail.com> writes: > > Dag-Erling Smørgrav <des@FreeBSD.org> 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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ZwZ0erARk2ZKAeBv>