Merge pull request #1105 from keloyang/check-kill-signal-num

Add num check for kill command
This commit is contained in:
Mrunal Patel 2016-10-17 15:15:28 -07:00 committed by GitHub
commit 0259c00a35
1 changed files with 7 additions and 2 deletions

View File

@ -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 {