summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSami Kerola <kerolasa@iki.fi>2013-04-13 20:54:41 +0100
committerKarel Zak <kzak@redhat.com>2013-04-26 13:26:06 +0200
commit944ab4b9316597d4a5616ff2c8d3f90cb1f3e9ad (patch)
tree20365431da3380a5a25f63888146eef4ee812014
parent1aba8336c094e26d189ce792606ecbac246209ce (diff)
downloadutil-linux-944ab4b9316597d4a5616ff2c8d3f90cb1f3e9ad.tar.gz
pg: check writing to a file was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
-rw-r--r--text-utils/pg.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/text-utils/pg.c b/text-utils/pg.c
index c00b7371..7ddf96bf 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;