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

Signal handling breaks parent code #1763

Closed
sssilver opened this issue May 3, 2018 · 9 comments
Closed

Signal handling breaks parent code #1763

sssilver opened this issue May 3, 2018 · 9 comments

Comments

@sssilver
Copy link
Contributor

sssilver commented May 3, 2018

Hi,

cloudflared imports github.com/coredns/coredns, which imports github.com/mholt/caddy.

It looks like coredns calls TrapSignals(), which installs its own signal handler for SIGTERM/SIGINT/etc, and since in UNIX/Linux there can only be one handler per process for these signals, that causes our own handlers in cloudflared to not get triggered.

The signal handler stuff in caddy makes sense for situations when it's being ran as a server, however when it's being used as a lib, it should probably be more mindful of what the parent code may choose to do with its own signal handlers.

For now, we have just commented out trapSignalsCrossPlatform() and some handlers in trapSignalsPosix() in the caddy package that we actually wanna handle in our own codebase. However, this is not a long-term solution. Ideally, we would be able to just pull coreDNS (and its transitive dependency caddy) from the origin and use it without having this issue.

Would it be possible to stop trapping signals in coredns?

Many thanks.

@miekg
Copy link
Member

miekg commented May 3, 2018 via email

@sssilver
Copy link
Contributor Author

sssilver commented May 3, 2018

Should we fix this and submit a PR?

@miekg
Copy link
Member

miekg commented May 3, 2018 via email

@sssilver
Copy link
Contributor Author

sssilver commented May 3, 2018

Quick question -- why are so many of the dependencies (including Caddy) listed in the ignored section of Gopkg.toml?

@miekg
Copy link
Member

miekg commented May 3, 2018 via email

@sssilver
Copy link
Contributor Author

sssilver commented May 3, 2018

Would you be happy if we moved caddy.TrapSignals() from init() to Run() in coremain/run.go?

@miekg
Copy link
Member

miekg commented May 3, 2018 via email

@sssilver
Copy link
Contributor Author

sssilver commented May 3, 2018

#1764 is ready for review.

@miekg
Copy link
Member

miekg commented May 9, 2018

/close

@corbot corbot bot closed this as completed May 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants