Browse code

Simplify the kill "SIG" prefix stripping code

Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)

Tianon Gravi authored on 2014/04/02 04:33:46
Showing 1 changed files
... ...
@@ -142,12 +142,8 @@ func (srv *Server) ContainerKill(job *engine.Job) engine.Status {
142 142
 		// The largest legal signal is 31, so let's parse on 5 bits
143 143
 		sig, err = strconv.ParseUint(job.Args[1], 10, 5)
144 144
 		if err != nil {
145
-			// The signal is not a number, treat it as a string
146
-			sig = uint64(signal.SignalMap[job.Args[1]])
147
-			if sig == 0 && strings.HasPrefix(job.Args[1], "SIG") {
148
-				// If signal is prefixed with SIG, try with it stripped (ie, "SIGKILL", etc)
149
-				sig = uint64(signal.SignalMap[job.Args[1][3:]])
150
-			}
145
+			// The signal is not a number, treat it as a string (either like "KILL" or like "SIGKILL")
146
+			sig = uint64(signal.SignalMap[strings.TrimPrefix(job.Args[1], "SIG")])
151 147
 			if sig == 0 {
152 148
 				return job.Errorf("Invalid signal: %s", job.Args[1])
153 149
 			}