Skip to content

Commit a367e4b

Browse files
author
Shukui Yang
committed
Add num check for kill command
Signed-off-by: Shukui Yang <[email protected]>
1 parent 26ebd6a commit a367e4b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

kill.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ signal to the init process of the "ubuntu01" container:
7777
if err != nil {
7878
return err
7979
}
80-
8180
if err := container.Signal(signal); err != nil {
8281
return err
8382
}
@@ -88,7 +87,13 @@ signal to the init process of the "ubuntu01" container:
8887
func parseSignal(rawSignal string) (syscall.Signal, error) {
8988
s, err := strconv.Atoi(rawSignal)
9089
if err == nil {
91-
return syscall.Signal(s), nil
90+
sig := syscall.Signal(s)
91+
for _, msig := range signalMap {
92+
if sig == msig {
93+
return sig, nil
94+
}
95+
}
96+
return -1, fmt.Errorf("unknown signal %q", rawSignal)
9297
}
9398
signal, ok := signalMap[strings.TrimPrefix(strings.ToUpper(rawSignal), "SIG")]
9499
if !ok {

0 commit comments

Comments
 (0)