Page MenuHomeFreeBSD

Add kqueue1(2) syscall
ClosedPublic

Authored by kib on Mar 26 2023, 12:43 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Apr 22, 10:34 AM
Unknown Object (File)
Mon, Apr 22, 9:48 AM
Unknown Object (File)
Wed, Apr 17, 11:52 PM
Unknown Object (File)
Feb 10 2024, 12:46 AM
Unknown Object (File)
Dec 22 2023, 11:21 PM
Unknown Object (File)
Dec 12 2023, 12:46 AM
Unknown Object (File)
Dec 8 2023, 9:38 PM
Unknown Object (File)
Dec 4 2023, 5:55 AM
Subscribers

Details

Summary

It adds an ability to atomically set O_CLOEXEC on the new kqueue descriptor.
I noted that something like this is missing during read of tokio-rs/mio kqueue implementation.

The naming is chosen to follow dup3()/accept4() pattern.

Diff Detail

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

Event Timeline

kib requested review of this revision.Mar 26 2023, 12:43 AM

I would maybe suggest KQ_CLOEXEC or KQUEUE_CLOEXEC as the flag name. In particular, if we ever needed kqueue2 in the future for some reason it would likely also still accept the flags argument and then the current name would be a bit odd. I think one of those names more closely matches SOCK_NONBLOCK and SOCK_CLOEXEC used with accept4.

This revision is now accepted and ready to land.Mar 27 2023, 5:53 PM

agree w/ @jhb on the flag name. I've also assumed that 2 is the first "version suffix" used, that kqueue is implicitly "kqueue1" , like dup, dup2, dup3. Was there ever a dup1 that has since been removed?

Other than quibbling over naming the change looks good to me

agree w/ @jhb on the flag name. I've also assumed that 2 is the first "version suffix" used, that kqueue is implicitly "kqueue1" , like dup, dup2, dup3. Was there ever a dup1 that has since been removed?

Other than quibbling over naming the change looks good to me

The number is the number of arguments, for the "new style" like dup3, pipe2, and accept4. dup2 pre-dates that scheme, but kqueue1 is consistent with the number-of-arguments suffix scheme.

dup(2) dates to the earliest days of Unix. It's present in V6, but dup2(2) doesn't appear until V7. If there ever was a dup1, no vestige of it survived in the Unix line.

Name quibbling and way-back-machine operation aside, the code looks fine. I generally agree with john and ed on naming issues they've raised.

Huh, learned something new today. In that case I'd just echo John's comment on the KQ1 flag prefix.

This revision now requires review to proceed.Mar 27 2023, 9:05 PM
jhb added inline comments.
lib/libc/sys/kqueue.2
99 ↗(On Diff #119526)

Wording suggestion borrowed from pipe2(2).

This revision is now accepted and ready to land.Mar 27 2023, 9:25 PM
kib marked an inline comment as done.Mar 27 2023, 10:09 PM
This revision was automatically updated to reflect the committed changes.