Also create epoll and pipe fds with close-on-exec (#155) (#219)
* Add the unix.O_CLOEXEC to the Pipe2 call
* Add unix.EPOLL_CLOEXEC to the Epoll call
diff --git a/inotify_poller.go b/inotify_poller.go
index cc7db4b..b33f2b4 100644
--- a/inotify_poller.go
+++ b/inotify_poller.go
@@ -40,12 +40,12 @@
poller.fd = fd
// Create epoll fd
- poller.epfd, errno = unix.EpollCreate1(0)
+ poller.epfd, errno = unix.EpollCreate1(unix.EPOLL_CLOEXEC)
if poller.epfd == -1 {
return nil, errno
}
// Create pipe; pipe[0] is the read end, pipe[1] the write end.
- errno = unix.Pipe2(poller.pipe[:], unix.O_NONBLOCK)
+ errno = unix.Pipe2(poller.pipe[:], unix.O_NONBLOCK|unix.O_CLOEXEC)
if errno != nil {
return nil, errno
}