changeset 761:6a558bf5de65

Elie De Brauwer pointed out that xputs() isn't reliably reporting errors because there's no flush. Rather than change the output granularity, flush before exit and check errors there. (We still need xputc() doing it so "yes" doesn't continue forever.)
author Rob Landley <rob@landley.net>
date Sun, 23 Dec 2012 01:25:27 -0600
parents 41b067739bd0
children f169d9708518
files main.c
diffstat 1 files changed, 1 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/main.c	Sun Dec 23 01:21:01 2012 -0600
+++ b/main.c	Sun Dec 23 01:25:27 2012 -0600
@@ -102,6 +102,7 @@
   if (!which) return;
   toy_init(which, argv);
   toys.which->toy_main();
+  if (fflush(NULL) || ferror(stdout)) perror_exit("write");
   exit(toys.exitval);
 }