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>
This commit is contained in:
1 parent
9d62c6fd0c
commit
4c22bda09b
1 file changed
+5
@@ -477,6 +477,11 @@ int main(int argc, char* argv[]) {
|
|||||||
if (jq_util_input_open_errors(input_state) != 0)
|
if (jq_util_input_open_errors(input_state) != 0)
|
||||||
ret = 2;
|
ret = 2;
|
||||||
|
|
||||||
|
if (fclose(stdout)!=0) {
|
||||||
|
fprintf(stderr,"Error: writing output failed: %s\n", strerror(errno));
|
||||||
|
ret = 2;
|
||||||
|
}
|
||||||
|
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user