diff options
author | Assaf Gordon <assafgordon@gmail.com> | 2015-03-06 13:54:53 -0500 |
---|---|---|
committer | Nicolas Williams <nico@cryptonector.com> | 2015-03-24 15:01:32 -0500 |
commit | 4c22bda09b4110ed7c2342fbe769d978cd5951ba (patch) | |
tree | e89b1a70b0c2d00118229ef5cbe47c1a7f78a3db /main.c | |
parent | 9d62c6fd0c739e2ec5925812084827c83df94922 (diff) |
detect and report output writing errors
Detect output errors when the program exits.
Currently:
$ echo '{}' | jq . > /dev/full && echo ok
ok
with the patch:
$ echo '{}' | jq . > /dev/full && echo ok
Error: writing output failed: No space left on device
also apply to hardware/network/other I/O errors.
Signed-off-by: Nicolas Williams <nico@cryptonector.com>
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -477,6 +477,11 @@ int main(int argc, char* argv[]) { if (jq_util_input_open_errors(input_state) != 0) ret = 2; + if (fclose(stdout)!=0) { + fprintf(stderr,"Error: writing output failed: %s\n", strerror(errno)); + ret = 2; + } + if (ret != 0) goto out; |