summaryrefslogtreecommitdiff
path: root/sfeed_opml_import.c
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2022-03-14 19:22:42 +0100
committerHiltjo Posthuma <hiltjo@codemadness.org>2022-03-15 14:46:46 +0100
commitfad48ffa27af96ee0d9489ded88f80c1eeb238dc (patch)
treedbd19eb13b389eb230325049d576c600bde606fa /sfeed_opml_import.c
parent813a96b517ae96716fb018ff93ab2d6a4bbcda95 (diff)
stricter error checking in file streams (input, output)
This also makes the programs exit with a non-zero status when a read or write error occurs. This makes checking the exit status more reliable in scripts. A simple example to simulate a disk with no space left: curl -s 'https://codemadness.org/atom.xml' | sfeed > f /mnt/test: write failed, file system is full echo $? 0 Which now produces: curl -s 'https://codemadness.org/atom.xml' | sfeed > f /mnt/test: write failed, file system is full write error: <stdout> echo $? 1 Tested with a small mfs on OpenBSD, fstab entry: swap /mnt/test mfs rw,nodev,nosuid,-s=1M 0 0
Diffstat (limited to 'sfeed_opml_import.c')
-rw-r--r--sfeed_opml_import.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/sfeed_opml_import.c b/sfeed_opml_import.c
index 0844b5c..6c0bd0e 100644
--- a/sfeed_opml_import.c
+++ b/sfeed_opml_import.c
@@ -101,5 +101,8 @@ main(void)
xml_parse(&parser);
fputs("}\n", stdout);
+ checkfileerror(stdin, "<stdin>", 'r');
+ checkfileerror(stdout, "<stdout>", 'w');
+
return 0;
}