]> granicus.if.org Git - procps-ng/commitdiff
tload: check write() return value
authorSami Kerola <kerolasa@iki.fi>
Sat, 21 Jan 2012 15:24:33 +0000 (16:24 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sat, 21 Jan 2012 15:24:33 +0000 (16:24 +0100)
Exit at rare events when writing to tty is unsuccessful.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
tload.c

diff --git a/tload.c b/tload.c
index 56a0b1c874c8f3674190dfd1858be44820e9ca9f..41ff2868db37b31dd56a85756c6f46bef5d1067c 100644 (file)
--- a/tload.c
+++ b/tload.c
@@ -187,8 +187,10 @@ int main(int argc, char **argv)
                if (i > 0)
                        screen[i] = ' ';
 
-               write(fd, "\033[H", 3);
-               write(fd, screen, scr_size - 1);
+               if (write(fd, "\033[H", 3) < 0)
+                       xerr(EXIT_FAILURE, _("writing to tty failed"));
+               if (write(fd, screen, scr_size - 1) < 0)
+                       xerr(EXIT_FAILURE, _("writing to tty failed"));
                pause();
        }
 }