Questions tagged [kqueue]

Kqueue is a scalable event notification interface introduced in FreeBSD 4.1,[1] also supported in NetBSD, OpenBSD, DragonflyBSD, and Mac OS X.

Kqueue provides efficient input and output event pipelines between the kernel and userland. Thus, it is possible to modify event filters as well as receive pending events while using only a single system call to kevent per main event loop iteration. This contrasts with older traditional polling system calls such as poll and select which are less efficient, especially when polling for events on a large number of file descriptors.

Kqueue does not only handle file descriptor events but is also used for various other notifications such as file modification monitoring, signals, asynchronous I/O events (AIO), child process state change monitoring and timers which support nanosecond resolution.

129 questions
1
vote
2 answers

What are the limitations of kqueue?

The documentation for libev (source) says that: Kqueue deserves special mention, as at the time of this writing, it was broken on all BSDs except NetBSD (usually it doesn't work reliably with anything but sockets and pipes, except on Darwin, where…
Dietrich Epp
  • 205,541
  • 37
  • 345
  • 415
1
vote
1 answer

Nonblocking connect does not report completion to kqueue

In MacOS I set up a read+write socket with O_NONBLOCK to connect to a remote server. I use kqueue to wait for and coordinate I/O events. The call to connect() immediately triggers EINPROGRESS, as it should. Soon after, the connection is completed.…
Dr H.
  • 51
  • 1
  • 7
1
vote
1 answer

Asynchronous sending data using kqueue

I have a server written in plain-old C accepting TCP connections using kqueue on FreeBSD. Incoming connections are accepted and added to a simple connection pool to keep track of the file handle. When data is received (on EVFILT_READ), I call…
Andrew
  • 11
  • 2
1
vote
0 answers

OSX using FSevents or Kernel queues to catch open for non-existent file

I'd like build a user-space tool that monitor any attempt to open non-existent file with specific path+name (it doesn't appear in filesystem). Looking at the the available option, the one that is closest to my need is using kevent framework. Here's…
Zohar81
  • 4,554
  • 5
  • 29
  • 82
1
vote
1 answer

broken kqueue warning when running Crystal on macOS Sierra

I decided to try playing with Crystal to check its speed and compatibility relative to Ruby. I downloaded the pre-built .pkg installer to my macOS Sierra system. My small test programs appear to run, but all produce the following message: $…
pjs
  • 18,696
  • 4
  • 27
  • 56
1
vote
0 answers

Why does poll indicate a kqueue watching a single empty Mach port set is readable?

I've got a kqueue watching a single item: an empty Mach port set. kevent64 says there are no events available, and select indicates the kqueue is not ready for reading. But poll says the kqueue is readable! - though this doesn't appear to be the…
Tom Seddon
  • 2,648
  • 1
  • 19
  • 28
1
vote
1 answer

Obtain siginfo_t when handling signals with kqueue

Is there a way to obtain siginfo_t struct when handling signals with kqueue? (On Linux when handling signal with epoll similar struct signalfd_siginfo is obtained by simply reading from signalfd)
1
vote
1 answer

Asynchronous I/O and time consuming work

I know that asynchronous socket programming is more scalable than synchronous. But there is one thing I don't really understand about it: If your event loop should be non blocking, how can you delegate time consuming work to another thread without…
Marco
  • 7,007
  • 2
  • 19
  • 49
1
vote
1 answer

File pointer appears to stop advancing

I am porting a log watching program from Linux, which uses sys/inotify.h, to OS X, which will use kqueues. The idea is that the kqueue will use the file descriptor to watch for changes to the file. Once the file has changed, a different function…
Chris
  • 354
  • 3
  • 13
1
vote
1 answer

When and where might kevent return errors?

Invalid items in the change list (or with EV_RECEIPT set) will cause kevent to return results with the EV_ERROR flag set. What other condition results in that flag? A Google search reveals that EV_RECEIPT support is related to "disambiguating error…
Potatoswatter
  • 134,909
  • 25
  • 265
  • 421
1
vote
1 answer

How do I trigger a kevent only when the socket recieves data?

Here are two little scripts that show how I am using kevents right now, and reproduce my problem. kqtest.py: import socket import select import threading server_sock = socket.socket(socket.AF_INET,…
Broseph
  • 1,655
  • 1
  • 18
  • 38
1
vote
1 answer

Do I need to unregister fd from epoll/kqueue when closing socket?

Is it true that if I close a socket its fd is auto purged from epoll and/or kqueue? If so, does it means there is no need to manually unregister the fd when closing fd? Actually I'm using Tornado, any advice on that would also be appreciated.
adamsmith
  • 5,759
  • 4
  • 27
  • 39
1
vote
1 answer

Monitor directory recursively for file additions/modifications/deletions

I need to watch a directory with several subdirectories, each of which has files which I need to monitor for file additions, modifications and deletions. I found some example code, and had to modify it slightly to get it working, but it doesn't…
OmnipotentEntity
  • 16,531
  • 6
  • 62
  • 96
1
vote
0 answers

FSEvents API and kqueue caused the real memory go up fast and app hang up

I want to monitor the change of folder. I can use FSEvents or kqueue as well, but the problem is memory go up so fast (more than 2GB for a tiny app) when I monitor a folder which lot of JPG images(I tested with 100 Photos). I see lot of ImageIO was…
user1002909
  • 174
  • 2
  • 11
1
vote
3 answers

Trying to use Kqueue in linux mint debian

I am Trying to use kqueue for doing an event oriented server in c when i compile my code it give me this error fatal error: sys/event.h: No such file or directory according to a tutorial that I am following to create the kqueue events that file have…
user2948982
  • 61
  • 1
  • 2
  • 8
1 2 3
8 9