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
Create inotify fd with close-on-exec #178
Conversation
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.
Thanks :-)
@@ -36,7 +37,7 @@ type Watcher struct { | |||
// NewWatcher establishes a new watcher with the underlying OS and begins waiting for events. | |||
func NewWatcher() (*Watcher, error) { | |||
// Create inotify fd | |||
fd, errno := unix.InotifyInit() | |||
fd, errno := unix.InotifyInit1(syscall.IN_CLOEXEC) |
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.
This should be unix.IN_CLOEXEC
since unix
is a more up-to-date version of the syscall
package.
Waiting on feedback/testing for ARM and PPC64 before merging. |
Can you provide steps to manually test that file descriptors are no longer leaking with this change? |
Notice the child process does not have an inotify fd |
I also tested this on ppc64le and it looks like both parent and child have an inotify fd:
|
@clnperez That's odd. I wonder if the |
I don't know why this wouldn't work. https://github.com/golang/sys/blob/master/unix/zsyscall_linux_ppc64le.go#L629 IN_CLOEXEC is defined with the same value as other platforms. So I wonder where the problem is. |
Yah, I don't know either. I had to add the syscalls for Pipe2 and InotifyInit, but InotifyInit1 is already there, so, hmm. I hope it just isn't something wonky on my system. |
Oh man. I forgot to rebuild fsnotify with this patch after I got my sys updated (since it was an older copy without the other syscalls added for ppc64le). Kiiiind of important. Sorry about the noise. It works fine on ppc64le. :) |
ping (sounds like ppc64 is ok. is there any other blocker?) |
thx |
resolves #155
(originally from #174)