--- gzip-1.3.12.orig/gzip.c +++ gzip-1.3.12/gzip.c @@ -182,6 +182,7 @@ int ascii = 0; /* convert end-of-lines to local OS conventions */ int to_stdout = 0; /* output to stdout (-c) */ +int used_stdout = 0; /* set to 1 if compressed output ever went to stdout */ int decompress = 0; /* decompress (-d) */ int force = 0; /* don't ask questions, compress links (-f) */ int no_name = -1; /* don't save or restore the original file name */ @@ -582,6 +583,13 @@ if (list && !quiet && file_count > 1) { do_list(-1, -1); /* print totals */ } + + /* if compressed data ever written to stdout, + * check for write errors that show up in close (NFS) */ + if ((used_stdout || to_stdout) && fclose(stdout) != 0) { + write_error(); + } + do_exit(exit_code); return exit_code; /* just to avoid lint warning */ } @@ -654,6 +662,7 @@ clear_bufs(); /* clear input and output buffers */ to_stdout = 1; + used_stdout = 1; part_nb = 0; if (decompress) {