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
2
votes
1 answer

Is it possible to poll a kqueue's file descriptor with `select()`?

When you create a kqueue with kqueue() you get back a file descriptor. But it appears that this file descriptor cannot be meaningfully polled with select(). I understand that the standard way to poll/read from a kqueue() is with kevent(...) but I'm…
ipmcc
  • 29,581
  • 5
  • 84
  • 147
2
votes
1 answer

Best Cocoa way to monitor several thousand files for move, delete and rename?

I have an app that keeps a database of files located on the user's machine or perhaps on networked volumes that may or may not be online. This database can potentially be several thousand files located in different folders. What is the best way to…
Trygve
  • 1,317
  • 10
  • 27
2
votes
4 answers

serving large file using select, epoll or kqueue

Nginx uses epoll, or other multiplexing techniques(select) for its handling multiple clients, i.e it does not spawn a new thread for every request unlike apache. I tried to replicate the same in my own test program using select. I could accept…
xask
  • 21
  • 1
  • 2
2
votes
1 answer

Reliable way to determine file size on POSIX/OS X given a file descriptor

I wrote a function to watch a file (given an fd) growing to a certain size including a timeout. I'm using kqueue()/kevent() to wait for the file to be "extended" but after I get the notification that the file grew I have to check the file size (and…
Johannes Weiss
  • 52,533
  • 16
  • 102
  • 136
2
votes
1 answer

Platform-agnostic way to monitor filesystem events

I'm currently developing a C++ application which should monitor the file system to reindex a set of files when they change. I am currently using Linux' inotify system, but would like the application to be as broadly portable to other systems as…
François Févotte
  • 19,520
  • 4
  • 51
  • 74
2
votes
2 answers

How to notify an abnormal client termination to server?

As the Title already says im looking for a way, to get notified when a client closes his Session unnormal. I'm using the freeBSD OS. The server is running with Xamount threads (depending on CPUcore amount). So I'm not forking, and there isn't a own…
dhein
  • 6,431
  • 4
  • 42
  • 74
2
votes
1 answer

Are there in AIX mechanisms EPOLL/KQUEUE or their equivalents?

Are there in AIX mechanisms EPOLL(Linux2.6)/KQUEUE(FreeBSD)/IO Completion Port(Windows) or their equivalents? And what kind of mechanisms are optimal for AIO on AIX for a large number of network connections? For example according to the Benchmarks,…
Alex
  • 12,578
  • 15
  • 99
  • 195
2
votes
1 answer

libevent kqueue doesn't work on fd returned from zmq_getsockopt()

ORIGINAL POST: I'm writing a service in C programming using libevent and zmq. Msg is pushed from python code to C service using PUSH-PULL pattern. fd received from zmq socket: void *receiver = zmq_socket (base.zmq_ctx, ZMQ_PULL); zmq_connect…
Pritesh Acharya
  • 1,596
  • 5
  • 15
  • 36
2
votes
1 answer

Nginx / PHP-FPM kevent() errors in stress testing

G'day, I'm running a FreeBSD box (9.1-RELEASE) with Nginx (1.2.7_1,1) and PHP-FPM (5.4.12). I'm having big problems with handling concurrent requests using Apache AB: ab -n 10000 -c 500 http://10.128.28.164/index.php The predominant error that I…
Pete
  • 437
  • 4
  • 11
1
vote
1 answer

kqueues on Mac OS X: strange event order

I monitor a file for changes in a separate thread using kqueues/ kevent(2). (I monitor a Python file for reparsing) I subscribe as following: EV_SET(&file_change, pyFileP, EVFILT_VNODE, EV_ADD | EV_CLEAR, NOTE_DELETE | NOTE_WRITE |…
buddhabrot
  • 1,558
  • 9
  • 14
1
vote
1 answer

Do NIO selectors use event notifications by default?

I found this article saying OpenJDK uses epoll on linux, but does anybody know if Selector implementations use kqueue, dev/poll etc over traditional polling where available?
Chris Mowforth
  • 6,689
  • 2
  • 26
  • 36
1
vote
1 answer

How to determine lost connection with kqueue?

I know that, here, on SO, are many questions themed like this. I've read through most of the similar questions and can not find an answer for my case. I use kqueue for server/client socket echo application. The program uses exclusively BSD socket…
user14063792468
  • 839
  • 12
  • 28
1
vote
1 answer

How to get KQueue to be available in Java in OSX?

My packages are as following: implementation("io.netty:netty-transport-native-epoll:$nettyVersion") implementation("io.netty:netty-transport-native-kqueue:$nettyVersion") …
Kemal Tezer Dilsiz
  • 3,739
  • 5
  • 24
  • 43
1
vote
1 answer

Need an explanation on wording of `kevent` filter

I have following lines for kevent in the man: EVFILT_TIMER Establishes an arbitrary timer identified by ident. When adding a timer, data specifies the moment to fire the timer (for NOTE_ABSTIME) or…
user14063792468
  • 839
  • 12
  • 28
1
vote
1 answer

How to use kqueue for file monitoring in asyncio?

I want to use kqueue to monitor files for changes. I can see how to use select.kqueue() in a threaded way. I'm searching for a way to use it with asyncio. I may have missed something really obvious here. I know that python uses kqueue for asyncio…
Philip Couling
  • 13,581
  • 5
  • 53
  • 85
1 2 3
8 9