diff --git a/internal/lockedfile/internal/filelock/filelock.go b/internal/lockedfile/internal/filelock/filelock.go index d373318..f0452f0 100644 --- a/internal/lockedfile/internal/filelock/filelock.go +++ b/internal/lockedfile/internal/filelock/filelock.go @@ -8,7 +8,6 @@ package filelock import ( - "errors" "io/fs" ) @@ -74,10 +73,3 @@ func (lt lockType) String() string { return "Unlock" } } - -// IsNotSupported returns a boolean indicating whether the error is known to -// report that a function is not supported (possibly for a specific input). -// It is satisfied by errors.ErrUnsupported as well as some syscall errors. -func IsNotSupported(err error) bool { - return errors.Is(err, errors.ErrUnsupported) -} diff --git a/internal/lockedfile/lockedfile.go b/internal/lockedfile/lockedfile.go index 8bd2ffb..f48124f 100644 --- a/internal/lockedfile/lockedfile.go +++ b/internal/lockedfile/lockedfile.go @@ -94,6 +94,11 @@ func (f *File) Close() error { err := closeFile(f.osFile.File) f.cleanup.Stop() + // f may be dead at the moment after we access f.cleanup, + // so the cleanup can fire before Stop completes. Keep f + // alive while we call Stop. See the documentation for + // runtime.Cleanup.Stop. + runtime.KeepAlive(f) return err }