Skip to content
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

docker-proxy cannot exit after send SIGINT #2421

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions portmapper/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net"
"os"
"os/exec"
"syscall"
"time"

"github.com/ishidawataru/sctp"
Expand Down Expand Up @@ -65,10 +66,26 @@ func (p *proxyCommand) Start() error {

func (p *proxyCommand) Stop() error {
if p.cmd.Process != nil {
if err := p.cmd.Process.Signal(os.Interrupt); err != nil {
if err := p.cmd.Process.Signal(syscall.SIGTERM); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason to replace SIGINT with SIGTERM?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was wondering as well; should we handle both ? (for backward compat)?

Copy link
Author

@mingfukuang mingfukuang Sep 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, i’m also not sure why send SIGINT other than SIGTERM. Proxy will deal with both of them . According appearance of problem, SIGINT looks can't got response. Besides, semantically speaking,SIGTERM could be suitable. so , i made this change.
Looking forward to your further suggestions :-)

return err
}
return p.cmd.Wait()

waitChan := make(chan error)
go func() {
waitChan <- p.cmd.Wait()
}()

t := time.NewTimer(15 * time.Second)
defer t.Stop()

select {
case result := <-waitChan:
return result
case <-t.C:
if err := p.cmd.Process.Signal(os.Kill); err != nil {
return err
}
}
}
return nil
}
Expand Down