From b2bae3c73817740b48a4698c6aa863d70234a64c Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 14 Jan 2017 02:41:48 -0500 Subject: On go 1.8, return os.ErrClosed on double-close. --- inotify/inotify.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'inotify/inotify.go') 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 . +// Copyright 2015-2017 Luke Shumaker . // // 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 -- cgit v1.2.3