]> git.ipfire.org Git - thirdparty/util-linux.git/blobdiff - term-utils/setterm.c
term-utils: verify writing to streams was successful
[thirdparty/util-linux.git] / term-utils / setterm.c
index 64fe0eb6ad5553fb188e09fee89e7615a5165545..5a652931b0813f6dab463bb40c1ef150826731ee 100644 (file)
 #include "c.h"
 #include "xalloc.h"
 #include "nls.h"
+#include "closestream.h"
 
 #if __GNU_LIBRARY__ < 5
 #ifndef __alpha__
@@ -1113,7 +1114,8 @@ perform_sequence(int vcterm) {
                        err(EXIT_DUMPFILE, _("can not open dump file %s for output"),
                                opt_sn_name); 
                screendump(opt_sn_num, F);
-               fclose(F);
+               if (close_stream(F) != 0)
+                       errx(EXIT_FAILURE, _("write error"));
        }
 
        /* -msg [on|off]. */
@@ -1225,6 +1227,7 @@ main(int argc, char **argv) {
        setlocale(LC_ALL, "");
        bindtextdomain(PACKAGE, LOCALEDIR);
        textdomain(PACKAGE);
+       atexit(close_stdout);
 
        if (argc < 2)
                bad_arg = TRUE;