Better handling of stdout errors
This commit is contained in:
1 parent
f4f5d8882d
commit
8a79f1d0a3
1 file changed
+3
-2
@@ -161,6 +161,7 @@ int main(int argc, char* argv[]) {
|
|||||||
int compiled = 0;
|
int compiled = 0;
|
||||||
int parser_flags = 0;
|
int parser_flags = 0;
|
||||||
int nfiles = 0;
|
int nfiles = 0;
|
||||||
|
int badwrite;
|
||||||
jv program_arguments = jv_array();
|
jv program_arguments = jv_array();
|
||||||
|
|
||||||
if (argc) progname = argv[0];
|
if (argc) progname = argv[0];
|
||||||
@@ -487,8 +488,8 @@ int main(int argc, char* argv[]) {
|
|||||||
ret = 2;
|
ret = 2;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
/* XXX We really should catch ENOSPC and such errors in jv_dumpf()! */
|
badwrite = ferror(stdout);
|
||||||
if (fclose(stdout)!=0) {
|
if (fclose(stdout)!=0 || badwrite) {
|
||||||
fprintf(stderr,"Error: writing output failed: %s\n", strerror(errno));
|
fprintf(stderr,"Error: writing output failed: %s\n", strerror(errno));
|
||||||
ret = 2;
|
ret = 2;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user