Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Apr 2023 13:30:01 GMT
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 20c9c3be5acc - main - kqueue: add close() calls to man page example
Message-ID:  <202304041330.334DU1kP003336@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=20c9c3be5acc66de9081f1f24456a62ba9395c4f

commit 20c9c3be5acc66de9081f1f24456a62ba9395c4f
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2023-03-31 18:50:26 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-04-04 13:29:53 +0000

    kqueue: add close() calls to man page example
    
    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.
    
    Reviewed by:    fernape, markj
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D39376
---
 lib/libc/sys/kqueue.2 | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/libc/sys/kqueue.2 b/lib/libc/sys/kqueue.2
index af60bb396d6a..cad4361f2b3c 100644
--- a/lib/libc/sys/kqueue.2
+++ b/lib/libc/sys/kqueue.2
@@ -773,6 +773,10 @@ main(int argc, char **argv)
 		printf("Something was written in '%s'\en", argv[1]);
 	}
     }
+
+    /* kqueues are destroyed upon close() */
+    (void)close(kq);
+    (void)close(fd);
 }
 .Ed
 .Sh ERRORS



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202304041330.334DU1kP003336>