Also create epoll and pipe fds with close-on-exec (#155)#219
Merged
cpuguy83 merged 2 commits intofsnotify:masterfrom Mar 12, 2019
Merged
Also create epoll and pipe fds with close-on-exec (#155)#219cpuguy83 merged 2 commits intofsnotify:masterfrom
cpuguy83 merged 2 commits intofsnotify:masterfrom
Conversation
8995176 to
64beda8
Compare
|
I can confirm that this fixes a problem I see, too. Bit surprised this wasn't fixed in #178. |
pwaller
previously approved these changes
Sep 1, 2017
|
Is there anything preventing this fix from being merged (other than needing a re-base on master)? This PR is from 2017 but the issue of these FDs leaking across execs is still present today. |
64beda8 to
df57317
Compare
Contributor
Author
|
I've rebased the patch onto current master, everything still seems to work fine. It would be good to have it merged. |
pwaller
previously approved these changes
Oct 14, 2018
* Add the unix.O_CLOEXEC to the Pipe2 call * Add unix.EPOLL_CLOEXEC to the Epoll call
df57317 to
92451cc
Compare
Contributor
|
I just force-pushed a no-op change to try and re-trigger the CI. |
Contributor
|
ugh 😞 CI issues due to golint not working on go1.8 anymore. |
Contributor
|
Finally, all green. Merging. Thanks! 🎉 ❤️ |
|
🎉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've signed the CLA.
What does this pull request do?
When creating a fsnotify.NewWatcher(), four file descriptors are opened: One for inotify, one for epoll and two for the two ends of a pipe. Only the inotify one has CLOEXEC set. This PR adds the CLOEXEC flag to all four file descriptors, preventing a leak in cases where execve is used e.g. to reload an executable on code change.
Where should the reviewer start?
I read the manpages of pipe2 and epoll_create2 to get an idea of the flags.
How should this be manually tested?
In a simple program which just opens a NewWatcher, does a syscall.Exec, and sleeps, the difference in the number of open file descriptors is visible in /proc//fd/