From: Richard W.M. Jones Date: Wed, 1 Jul 2009 15:36:13 +0000 (+0100) Subject: Fix error handling of external sfdisk command. X-Git-Tag: 1.0.55~25 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=fe27753ae5925cbe50042e47115364a57aadbbd7;p=libguestfs.git 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. --- diff --git a/daemon/sfdisk.c b/daemon/sfdisk.c index 95f04af..6ff2736 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; }