]> go.fuhry.dev Git - fsnotify.git/commitdiff
Also create epoll and pipe fds with close-on-exec (#155) (#219)
authorJohannes Ebke <johannes@ebke.org>
Tue, 12 Mar 2019 18:14:46 +0000 (19:14 +0100)
committerBrian Goff <cpuguy83@gmail.com>
Tue, 12 Mar 2019 18:14:46 +0000 (11:14 -0700)
* Add the unix.O_CLOEXEC to the Pipe2 call
* Add unix.EPOLL_CLOEXEC to the Epoll call

inotify_poller.go

index cc7db4b22ef5bdaf81c5cc629d3062fcf544e202..b33f2b4d4b799ba4b74f85c2ec188e5388928c0c 100644 (file)
@@ -40,12 +40,12 @@ func newFdPoller(fd int) (*fdPoller, error) {
        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
        }