seq: exit on write errors
authorDenys Vlasenko <vda.linux@googlemail.com>
Sun, 17 Oct 2010 10:44:39 +0000 (12:44 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sun, 17 Oct 2010 10:44:39 +0000 (12:44 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
coreutils/seq.c

index 8be25360ffd21a2c9a510dd426d648d04d74b872..22bf3ec9de141c7b7e1e7ac77d2bd9c45059af4b 100644 (file)
@@ -86,7 +86,8 @@ int seq_main(int argc, char **argv)
        v = first;
        n = 0;
        while (increment >= 0 ? v <= last : v >= last) {
-               printf("%s%0*.*f", sep, width, frac_part, v);
+               if (printf("%s%0*.*f", sep, width, frac_part, v) < 0)
+                       break; /* I/O error, bail out (yes, this really happens) */
                sep = opt_s;
                /* v += increment; - would accumulate floating point errors */
                n++;