Add num check for kill command
Signed-off-by: Shukui Yang <yangshukui@huawei.com>
This commit is contained in:
parent
26ebd6ab63
commit
a367e4b95c
9
kill.go
9
kill.go
|
@ -77,7 +77,6 @@ signal to the init process of the "ubuntu01" container:
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := container.Signal(signal); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -88,7 +87,13 @@ signal to the init process of the "ubuntu01" container:
|
|||
func parseSignal(rawSignal string) (syscall.Signal, error) {
|
||||
s, err := strconv.Atoi(rawSignal)
|
||||
if err == nil {
|
||||
return syscall.Signal(s), nil
|
||||
sig := syscall.Signal(s)
|
||||
for _, msig := range signalMap {
|
||||
if sig == msig {
|
||||
return sig, nil
|
||||
}
|
||||
}
|
||||
return -1, fmt.Errorf("unknown signal %q", rawSignal)
|
||||
}
|
||||
signal, ok := signalMap[strings.TrimPrefix(strings.ToUpper(rawSignal), "SIG")]
|
||||
if !ok {
|
||||
|
|
Loading…
Reference in New Issue