mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-30 16:35:24 +00:00
virsh: demonstrate use of VIR_AUTOPTR(virshDomain) on 'send-process-signal'
Refactor the command code to use the new type. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
96143986ca
commit
ec1ea11988
@ -8834,8 +8834,7 @@ static int getSignalNumber(vshControl *ctl, const char *signame)
|
||||
static bool
|
||||
cmdSendProcessSignal(vshControl *ctl, const vshCmd *cmd)
|
||||
{
|
||||
virDomainPtr dom;
|
||||
bool ret = false;
|
||||
VIR_AUTOPTR(virshDomain) dom = NULL;
|
||||
const char *signame;
|
||||
long long pid_value;
|
||||
int signum;
|
||||
@ -8844,24 +8843,20 @@ cmdSendProcessSignal(vshControl *ctl, const vshCmd *cmd)
|
||||
return false;
|
||||
|
||||
if (vshCommandOptLongLong(ctl, cmd, "pid", &pid_value) < 0)
|
||||
goto cleanup;
|
||||
return false;
|
||||
|
||||
if (vshCommandOptStringReq(ctl, cmd, "signame", &signame) < 0)
|
||||
goto cleanup;
|
||||
return false;
|
||||
|
||||
if ((signum = getSignalNumber(ctl, signame)) < 0) {
|
||||
vshError(ctl, _("malformed signal name: %s"), signame);
|
||||
goto cleanup;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (virDomainSendProcessSignal(dom, pid_value, signum, 0) < 0)
|
||||
goto cleanup;
|
||||
return false;
|
||||
|
||||
ret = true;
|
||||
|
||||
cleanup:
|
||||
virshDomainFree(dom);
|
||||
return ret;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user