From cdd2a8c360c70d16804ace7cc923a6c6bb7c9ca9 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Wed, 4 Apr 2012 19:44:04 +0200 Subject: term-utils: verify writing to streams was successful Signed-off-by: Sami Kerola --- term-utils/setterm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'term-utils/setterm.c') diff --git a/term-utils/setterm.c b/term-utils/setterm.c index 64fe0eb6a..5a652931b 100644 --- a/term-utils/setterm.c +++ b/term-utils/setterm.c @@ -121,6 +121,7 @@ #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; -- cgit v1.2.3-55-g7522