Better handling of stdout errors

This commit is contained in:
Nicolas Williams committed 2015-05-29 11:50:08 -05:00
1 parent f4f5d8882d
commit 8a79f1d0a3
1 file changed
+3 -2
+3 -2
View File
@@ -161,6 +161,7 @@ int main(int argc, char* argv[]) {
int compiled = 0;
int parser_flags = 0;
int nfiles = 0;
int badwrite;
jv program_arguments = jv_array();
if (argc) progname = argv[0];
@@ -487,8 +488,8 @@ int main(int argc, char* argv[]) {
ret = 2;
out:
/* XXX We really should catch ENOSPC and such errors in jv_dumpf()! */
if (fclose(stdout)!=0) {
badwrite = ferror(stdout);
if (fclose(stdout)!=0 || badwrite) {
fprintf(stderr,"Error: writing output failed: %s\n", strerror(errno));
ret = 2;
}