Eric Blake <[EMAIL PROTECTED]> wrote: > According to Paul Eggert on 9/29/2006 11:38 AM: >> >> I like the basic idea. As I understand it this affects only programs >> that issue "warnings" (i.e., they output to stderr but then continue >> without affecting the exit status) but it's useful for that case. >> >> However, wouldn't this implementation be simpler? >> >> if (close_stream (stderr) != 0) >> _exit (exit_failure); >> >> At any rate let's wait until coreutils 6.3 gets out. > > coreutils 6.3 is out. OK to apply this simpler version? I've updated the > M4 testsuite to expose failures if this patch is not applied.
I've just checked in this change: [ChangeLog] 2006-09-29 Bruno Haible <[EMAIL PROTECTED]> * modules/closeout (Description): Mention stderr too. [lib/ChangeLog] 2006-09-29 Bruno Haible <[EMAIL PROTECTED]> and Paul Eggert <[EMAIL PROTECTED]> * closeout.c (close_stdout): Also close stderr. * closeout.h: Update comment. Index: modules/closeout =================================================================== RCS file: /sources/gnulib/gnulib/modules/closeout,v retrieving revision 1.15 diff -u -r1.15 closeout --- modules/closeout 21 Aug 2006 21:46:31 -0000 1.15 +++ modules/closeout 6 Oct 2006 13:56:41 -0000 @@ -1,5 +1,5 @@ Description: -Close standard output, exiting with a diagnostic on error. +Close standard output and standard error, exiting with a diagnostic on error. Files: lib/closeout.h Index: lib/closeout.c =================================================================== RCS file: /sources/gnulib/gnulib/lib/closeout.c,v retrieving revision 1.21 diff -u -r1.21 closeout.c --- lib/closeout.c 13 Sep 2006 22:38:14 -0000 1.21 +++ lib/closeout.c 6 Oct 2006 13:56:41 -0000 @@ -1,4 +1,4 @@ -/* Close standard output, exiting with a diagnostic on error. +/* Close standard output and standard error, exiting with a diagnostic on error. Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2006 Free Software Foundation, Inc. @@ -46,6 +46,8 @@ /* Close standard output. On error, issue a diagnostic and _exit with status 'exit_failure'. + Also close standard error. On error, _exit with status 'exit_failure'. + Since close_stdout is commonly registered via 'atexit', POSIX and the C standard both say that it should not call 'exit', because the behavior is undefined if 'exit' is called more than @@ -78,4 +80,7 @@ _exit (exit_failure); } + + if (close_stream (stderr) != 0) + _exit (exit_failure); } Index: lib/closeout.h =================================================================== RCS file: /sources/gnulib/gnulib/lib/closeout.h,v retrieving revision 1.8 diff -u -r1.8 closeout.h --- lib/closeout.h 14 May 2005 06:03:57 -0000 1.8 +++ lib/closeout.h 6 Oct 2006 13:56:41 -0000 @@ -1,6 +1,6 @@ -/* Close standard output. +/* Close standard output and standard error. - Copyright (C) 1998, 2000, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 1998, 2000, 2003, 2004, 2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by