cfdisk: check writing to a file descriptor was successful

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2013-04-13 20:54:48 +01:00 committed by Karel Zak
parent dd79e7c9d0
commit c8e8b916ab
1 changed files with 6 additions and 2 deletions

View File

@ -406,8 +406,12 @@ static void
fdexit(int ret) {
if (opened) {
if (changed)
fsync(fd);
close(fd);
if (close_fd(fd) != 0) {
fprintf(stderr, _("write failed\n"));
exit(2);
}
else
close(fd);
}
if (changed) {
fprintf(stderr, _("Disk has been changed.\n"));