[PATCH 13/33] pg: check writing to a file was successful

Sami Kerola
2013-04-13T19:55:45Z

text-utils/pg.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/text-utils/pg.c b/text-utils/pg.c
index c00b737..7ddf96b 100644
--- a/text-utils/pg.c
+++ b/text-utils/pg.c
@@ -1228,7 +1228,14 @@ static void pgfile(FILE *f, const char *name)
/* No error check for compat. */
fwrite_all(b, sizeof *b, sz, save);
}
- fclose(save);
+ if (close_stream(save) != 0) {
+ cmd.count = errno;
+ mesg(_("write failed"));
+ mesg(": ");
+ mesg(p);
+ mesg(strerror(cmd.count));
+ goto newcmd;
+ }
fseeko(fbuf, (off_t)0, SEEK_END);
mesg(_("saved"));
goto newcmd;
--
1.8.2.1