summaryrefslogtreecommitdiff
path: root/inotify/inotify.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2017-01-14 02:41:48 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2017-01-14 02:41:48 -0500
commitb2bae3c73817740b48a4698c6aa863d70234a64c (patch)
tree31cc4782cc8b79de5448b112f0641d0ac72e41d3 /inotify/inotify.go
parent3b2e46671e6d8356f9e236255bc0df805720cc3b (diff)
On go 1.8, return os.ErrClosed on double-close.HEADmaster
Diffstat (limited to 'inotify/inotify.go')
-rw-r--r--inotify/inotify.go14
1 files changed, 6 insertions, 8 deletions
diff --git a/inotify/inotify.go b/inotify/inotify.go
index d7e7044..7c80a00 100644
--- a/inotify/inotify.go
+++ b/inotify/inotify.go
@@ -1,4 +1,4 @@
-// Copyright 2015-2016 Luke Shumaker <lukeshu@sbcglobal.net>.
+// Copyright 2015-2017 Luke Shumaker <lukeshu@sbcglobal.net>.
//
// This is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as
@@ -157,16 +157,14 @@ func (in *Inotify) RmWatch(wd Wd) error {
// Close closes the inotify instance; further calls to this object
// will error.
+//
+// In the event of a double-close condition, in go <= 1.7, this
+// returns an os.SyscallError wrapping unix.EBADF; on go >= 1.8, it
+// returns os.ErrClosed.
func (in *Inotify) Close() (err error) {
defer func() {
if r := recover(); r != nil {
- // This is a double-close condition.
- //
- // Choices for the error:
- // - Linux: EBADF
- // - os.File: unix.EINVAL
- // - net.netFD: net.errClosing = errors.New(...)
- err = os.NewSyscallError("close", unix.EBADF)
+ err = errClosed
}
}()
close(in.ch) // will panic if already closed; hence above