Skip to content

Commit

Permalink
Open files with CLOEXEC
Browse files Browse the repository at this point in the history
Fix #270
  • Loading branch information
linxiulei committed Oct 25, 2018
1 parent ccc981b commit b099992
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions inotify_poller.go
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion open_mode_bsd.go
Expand Up @@ -8,4 +8,4 @@ package fsnotify

import "golang.org/x/sys/unix"

const openMode = unix.O_NONBLOCK | unix.O_RDONLY
const openMode = unix.O_NONBLOCK | unix.O_RDONLY | unix.O_CLOEXEC
2 changes: 1 addition & 1 deletion open_mode_darwin.go
Expand Up @@ -9,4 +9,4 @@ package fsnotify
import "golang.org/x/sys/unix"

// note: this constant is not defined on BSD
const openMode = unix.O_EVTONLY
const openMode = unix.O_EVTONLY | unix.O_CLOEXEC

0 comments on commit b099992

Please sign in to comment.