more: exit if write to stdout errors out
authorDenys Vlasenko <dvlasenk@redhat.com>
Mon, 13 Dec 2010 13:28:38 +0000 (14:28 +0100)
committerDenys Vlasenko <dvlasenk@redhat.com>
Mon, 13 Dec 2010 13:28:38 +0000 (14:28 +0100)
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
util-linux/more.c

index 788609a081c455a85a04d9a8ac27d8ea8ff3121c..ecac928215a0157c58c844bfa628e51b0d7853d6 100644 (file)
@@ -191,6 +191,9 @@ int more_main(int argc UNUSED_PARAM, char **argv)
                        }
                        /* My small mind cannot fathom backspaces and UTF-8 */
                        putchar(c);
+
+                       if (ferror(stdout)) /* if tty was destroyed (closed xterm, etc) */
+                               goto end;
                }
                fclose(file);
                fflush_all();