Page MenuHomeFreeBSD

kqueue: add close() calls to man page example
ClosedPublic

Authored by emaste on Mar 31 2023, 7:10 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Jan 9, 9:45 AM
Unknown Object (File)
Thu, Jan 9, 6:13 AM
Unknown Object (File)
Nov 26 2024, 3:30 PM
Unknown Object (File)
Nov 26 2024, 3:30 PM
Unknown Object (File)
Nov 26 2024, 3:30 PM
Unknown Object (File)
Nov 26 2024, 3:29 PM
Unknown Object (File)
Nov 26 2024, 3:07 PM
Unknown Object (File)
Nov 7 2024, 2:09 PM
Subscribers

Details

Summary
There is no real need to close descriptors before a process exits, but
these close calls demonstrate by example that kqueue descriptors occupy
the same namespace as other file descriptors.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

emaste created this revision.

linux inotify man page states

*  When all file descriptors referring to an inotify instance
   have been closed (using close(2)), the underlying object and
   its resources are freed for reuse by the kernel; all
   associated watches are automatically freed.

perhaps we should have similar text

LGTM!

Thank your for this. It makes the example clearer in intention. Notice though, that the two calls to close(2) will never be reached due to the infinite loop.

linux inotify man page states

*  When all file descriptors referring to an inotify instance
   have been closed (using close(2)), the underlying object and
   its resources are freed for reuse by the kernel; all
   associated watches are automatically freed.

perhaps we should have similar text

When that paragraph talks about ..all file descriptors referring to an inotify instance..., what does it mean? Calling dup(2) on the fd returned by inotify_init(2)? How else is it possible to have more than one fd for an inotify instance?

This revision is now accepted and ready to land.Apr 1 2023, 4:51 PM

My comments are just meant as suggestions.

lib/libc/sys/kqueue.2
776
777

I'd be pedantic and write (void)close(kq);.

incorporate markj suggestion

This revision now requires review to proceed.Apr 3 2023, 8:37 PM

Calling dup(2) on the fd returned by inotify_init(2)? How else is it possible to have more than one fd for an inotify instance?

A process forking could be another example.

This revision is now accepted and ready to land.Apr 4 2023, 12:48 PM
This revision was automatically updated to reflect the committed changes.