在 2012-10-08一的 20:05 -0600,Eric Blake写道: > On 10/08/2012 07:51 PM, liguang wrote: > > this usage was suggested by man-page of waitpid, > > returns true if the child terminated normally > > NACK. virCommandRun already did this for you. right, but not exactly, virCommandRun will leave raw exit-status out of there, so if the waited-command exit with a code '1', then the caller of virCommandRun will see exit-status value 0x100, and report an odd '256' exit-status. obviously, the low byte has no meaning. originally I think I should not handle this exit-status, so I use WIFEXITED, if I have to take care of it, at least the low byte should be ignored and report a correct exit-status value '1' > > > > > Signed-off-by: liguang <lig.fnst@xxxxxxxxxxxxxx> > > --- > > src/util/hooks.c | 2 +- > > 1 files changed, 1 insertions(+), 1 deletions(-) > > > > diff --git a/src/util/hooks.c b/src/util/hooks.c > > index f5890d2..55b98ca 100644 > > --- a/src/util/hooks.c > > +++ b/src/util/hooks.c > > @@ -280,7 +280,7 @@ virHookCall(int driver, > > virCommandSetOutputBuffer(cmd, output); > > > > ret = virCommandRun(cmd, &exitstatus); > > - if (ret == 0 && exitstatus != 0) { > > + if (ret == 0 && WIFEXITED(exitstatus) == 0) { > > virReportError(VIR_ERR_HOOK_SCRIPT_FAILED, > > _("Hook script %s %s failed with error code %d"), > > path, drvstr, exitstatus); > > > -- liguang lig.fnst@xxxxxxxxxxxxxx FNST linux kernel team -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list