diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2009-07-01 16:36:13 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2009-07-01 16:36:13 +0100 |
commit | fe27753ae5925cbe50042e47115364a57aadbbd7 (patch) | |
tree | c1551273831fe7659a1e5125888f6c049e6b9ba0 /daemon/sfdisk.c | |
parent | 896079e29b4d49c6c18ac3316a94bfbe2f307648 (diff) | |
download | libguestfs-fe27753ae5925cbe50042e47115364a57aadbbd7.tar.gz libguestfs-fe27753ae5925cbe50042e47115364a57aadbbd7.tar.xz libguestfs-fe27753ae5925cbe50042e47115364a57aadbbd7.zip |
Fix error handling of external sfdisk command.
Should use 'pclose' instead of 'fclose' (although fclose happens
to work because of glibc internals).
The result of pclose is the exit status of the command, so we
need to test this is != 0.
Diffstat (limited to 'daemon/sfdisk.c')
-rw-r--r-- | daemon/sfdisk.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/daemon/sfdisk.c b/daemon/sfdisk.c index 95f04af4..6ff2736f 100644 --- a/daemon/sfdisk.c +++ b/daemon/sfdisk.c @@ -63,14 +63,13 @@ sfdisk (char *device, int n, int cyls, int heads, int sectors, for (i = 0; lines[i] != NULL; ++i) { if (fprintf (fp, "%s\n", lines[i]) < 0) { reply_with_perror (buf); - fclose (fp); + pclose (fp); return -1; } } - if (fclose (fp) == EOF) { - reply_with_perror (buf); - fclose (fp); + if (pclose (fp) != 0) { + reply_with_error ("%s: external command failed", buf); return -1; } |