kquser

command
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2026 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

User demonstrates kqueue(2) send and receive a user event.

Synopsis:

kquser

Background:

BSD-like systems (*BSD, MacOS, etc.) provide kqueue(2) to monitor events from a wide range of systems: file system, processes, signals, jails, timer, user, etc. (MacOS does not include jails).

For the record, Linux has similar mechanism, implemented via select(2), poll(2), epoll(7), or inotify(7).

Kqueue(2) is a stateful mechanism: Kernel keeps track of subscriptions. It is important to close kqueue(2) when done to clean up resources.

Kqueue(2) provides a single function to manage and poll events. It guarantees to process manage-events first, and then update the poll-events. Even though it is possible to use both kinds of events in the same call to kevent(2), it is best to separate the two.

Example:

This example demonstrates the following aspects of working with kqueue(2):

- Create and cleanup kqueue(2) Kernel resources. - Subscribe to User events. - Send and receive user events.

Output:

2026/01/05 16:13:50 sent event event-id-two
2026/01/05 16:13:50 received event event-id-two

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL