Allow "SIG" prefix on signal names in docker kill ("SIGKILL", etc)

This way, we can use both `docker kill -s INT some_container` and `docker kill -s SIGINT some_container` and both will do nice things for us. :)

Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
This commit is contained in:
Tianon Gravi
2014-04-01 11:01:07 -06:00
parent f6f059d99a
commit 4cb602afa0
2 changed files with 11 additions and 2 deletions
+4
View File
@@ -144,6 +144,10 @@ func (srv *Server) ContainerKill(job *engine.Job) engine.Status {
if err != nil {
// The signal is not a number, treat it as a string
sig = uint64(signal.SignalMap[job.Args[1]])
if sig == 0 && strings.HasPrefix(job.Args[1], "SIG") {
// If signal is prefixed with SIG, try with it stripped (ie, "SIGKILL", etc)
sig = uint64(signal.SignalMap[job.Args[1][3:]])
}
if sig == 0 {
return job.Errorf("Invalid signal: %s", job.Args[1])
}