Merge pull request #1105 from keloyang/check-kill-signal-num
Add num check for kill command
This commit is contained in:
commit
0259c00a35
9
kill.go
9
kill.go
|
@ -77,7 +77,6 @@ signal to the init process of the "ubuntu01" container:
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := container.Signal(signal); err != nil {
|
if err := container.Signal(signal); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -88,7 +87,13 @@ signal to the init process of the "ubuntu01" container:
|
||||||
func parseSignal(rawSignal string) (syscall.Signal, error) {
|
func parseSignal(rawSignal string) (syscall.Signal, error) {
|
||||||
s, err := strconv.Atoi(rawSignal)
|
s, err := strconv.Atoi(rawSignal)
|
||||||
if err == nil {
|
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")]
|
signal, ok := signalMap[strings.TrimPrefix(strings.ToUpper(rawSignal), "SIG")]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
Loading…
Reference in New Issue