Skip to content
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

Merged
merged 2 commits into from Oct 11, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion inotify.go
Expand Up @@ -14,6 +14,7 @@ import (
"path/filepath"
"strings"
"sync"
"syscall"
"unsafe"

"golang.org/x/sys/unix"
Expand All @@ -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)
Copy link
Contributor

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.

if fd == -1 {
return nil, errno
}
Expand Down