[libvirt] [PATCH] virsh: send-process-signal: add support for '-NUM' style of signal nums

From: Chen Hanxiao <chenhanxiao@gmail.com> As kill(1), add support for sending signal in form of "9" as well as "-9". Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com> --- tools/virsh-domain.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 7194153..b96b8fd 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -8254,9 +8254,14 @@ static int getSignalNumber(vshControl *ctl, const char *signame) for (i = 0; signame[i]; i++) lower[i] = c_tolower(signame[i]); + if (STRPREFIX(lower, "-")) + lower += 1; + if (virStrToLong_i(lower, NULL, 10, &signum) >= 0) goto cleanup; + lower = tmp; + if (STRPREFIX(lower, "sig_")) lower += 4; else if (STRPREFIX(lower, "sig")) -- 1.8.3.1

On Fri, Sep 23, 2016 at 06:09:02PM +0800, Chen Hanxiao wrote:
From: Chen Hanxiao <chenhanxiao@gmail.com>
As kill(1), add support for sending signal in form of "9" as well as "-9".
I'm not a fan of this as it introduces ambiguity which could hurt us if we want to rewrite/extend the option parser - you can't distinguish an option argument (-9) with name of "9", from a positional argument with a value of "-9". Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (2)
-
Chen Hanxiao
-
Daniel P. Berrange