Hi
There is a bug in dd --- if libc doesn't have __fpending, coreutils will
use a stub that always returns 1. A side effect of this stub is that
close_stdout always calls fclose(stdout) --- it normally doesn't matter
for most utilities except dd --- dd calls close(1) on its own and later
fclose(stdout) in atexit(close_stdout) will report error.
This patch fixes the problem by moving atexit(close_stdout) to usage()
function --- its the only function in dd that uses stdout.
Mikulas
--- src/dd.c_ 2007-01-06 04:39:41.000000000 +0200
+++ src/dd.c 2007-01-06 04:41:58.000000000 +0200
@@ -396,6 +396,11 @@
void
usage (int status)
{
+ /* usage is the only function that uses stdout --- so set close callback
here.
+ close_stdout can't be called on normal dd branch because it would report
+ failure because of close (STDOUT_FILENO) */
+ atexit (close_stdout);
+
if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
@@ -1636,9 +1641,6 @@
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
- /* Arrange to close stdout if parse_long_options exits. */
- atexit (close_stdout);
-
page_size = getpagesize ();
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, VERSION,
_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils