diff -up tar-1.17/src/buffer.c.stdoutlist tar-1.17/src/buffer.c --- tar-1.17/src/buffer.c.stdoutlist 2007-06-01 12:17:10.000000000 +0200 +++ tar-1.17/src/buffer.c 2007-12-11 14:23:30.000000000 +0100 @@ -465,6 +465,13 @@ _open_archive (enum access_mode wanted_a records_read = 0; + struct stat st_buf; + ino_t stdout_ino = fstat(STDOUT_FILENO, &st_buf) == -1 ? + 0 : st_buf.st_ino; + ino_t archive_ino = stat(archive_name_array[0], &st_buf) == -1 ? + 0 : st_buf.st_ino; + bool archive_is_stdout = (archive_ino != 0 && archive_ino == stdout_ino); + if (use_compress_program_option) { switch (wanted_access) @@ -486,10 +493,10 @@ _open_archive (enum access_mode wanted_a if (!index_file_name && wanted_access == ACCESS_WRITE - && strcmp (archive_name_array[0], "-") == 0) + && (strcmp (archive_name_array[0], "-") == 0 || archive_is_stdout)) stdlis = stderr; } - else if (strcmp (archive_name_array[0], "-") == 0) + else if (strcmp (archive_name_array[0], "-") == 0 || archive_is_stdout) { read_full_records = true; /* could be a pipe, be safe */ if (verify_option)