New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow "SIG" prefix on signal names in docker kill
("SIGKILL", etc)
#4947
Conversation
@tianon travis failed |
hahahaha, gofmt :) Thanks, will update. |
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)
Fixed. :) |
@@ -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:]]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather use strings.TrimPrefix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this. we already rely on strings.HadPrefix()
so we know that we can safely do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just always use strings.TrimPrefix and not worry about the if?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we could :)
LGTM. WIth or without the changes :) |
LGTM |
Allow "SIG" prefix on signal names in `docker kill` ("SIGKILL", etc)
Hah, couldn't even wait for me to fix it? :) |
This way, we can use both
docker kill -s INT some_container
anddocker kill -s SIGINT some_container
and both will do nice things for us. :)