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

Listening socket backlog size. I can not understand the wording of a manpage

My man pages for kqueue give me the following: EVFILT_READ Takes a descriptor as the identifier, and returns whenever there is data available to read. The behavior of the filter is slightly…
user14063792468
  • 839
  • 12
  • 28
0
votes
0 answers

The kqueue system call and non-blocking connect. What code should I use to test for an error in the situation?

Today, I was making small changes to my Linux code. The code is a kind of ping-pong network program. The client writes "Hello", the server responds with "Hello". That is all to it. Now I use FreeBSD. So naturally epoll mechanism being replaced by…
user14063792468
  • 839
  • 12
  • 28
0
votes
1 answer

read event is received before the write one in kqueue

I'm having an issue with my code, I'm trying to create an HTTP server using C++ 98 on MacOS, and I'm expecting the block of read to be executed before the write one, but the opposite is happening and I don't know why. So I'm expecting to read first…
REVERSI
  • 59
  • 5
0
votes
0 answers

getting response only on the first time with socket programming

I'm trying to create an HTTP server using C++ 98. The issue is that, every time I launch my server, I get the response, sending again the request from the same browser tab, and the browser keeps loading. In my kqueue, it seems like the block for…
REVERSI
  • 59
  • 5
0
votes
1 answer

`select` works but `kqueue` doesn't when waiting on X11 connection

This blocks until there's an X11 event available: int x11_fd = ConnectionNumber(display); fd_set in_fds; FD_ZERO(&in_fds); FD_SET(x11_fd, &in_fds); select(x11_fd + 1, &in_fds, NULL, NULL, NULL); This just immediately returns: int x11_fd =…
Name McChange
  • 2,750
  • 5
  • 27
  • 46
0
votes
0 answers

Prior to macOS Sierra, why didn't XNU handle THREAD_RESTART in its kqueue_scan_continue function?

I'm trying to find the cause of a nasty kernel panic triggered by Chromium Legacy, a project to backport modern versions of Chromium to old versions of macOS (10.7 – 10.10). The kernel panic occurs when the kqueue_scan_continue function is called…
Wowfunhappy
  • 168
  • 7
0
votes
2 answers

File monitor stop after save file

I'm trying to monitor the edition of a single file using kqueue through a wrapper called UKKQueue available here. This wrapper is very simple, here is the test code I'm using: @implementation FileMonitorTestAppDelegate @synthesize window; -…
Bruno Berisso
  • 1,091
  • 11
  • 33
0
votes
0 answers

How to create or manage Libuv TCP server in a c++ fuction?

I am trying to create a TCP server in a function int create_server(int port_number, char ip_addr_string[IPV4_ADDR_SIZE]) which is called in main. When I run the c++ code given below: Assertion failed: (w->fd >= 0), function uv__io_poll, file…
Tyson X
  • 1
  • 1
0
votes
2 answers

how to determine if a file is completely downloaded using kqueue?

I want to implement a function which monitor a directory and perform some action when a new file is downloaded from the Internet, but found it difficult to determine if the file is completely downloaded, is there a way to do that?
SolskGaer
  • 71
  • 7
0
votes
1 answer

how do I use kevent and select?

kevent's file descriptor returned by kqueue() can be used as input to select() or kevent(). What are the advantages of using this method? Suppose kevent is waiting on a list of descriptors by using kevent() and there are some activities on that…
badcompany
  • 1,263
  • 2
  • 9
  • 9
0
votes
1 answer

How to add a `kevent` to a `kqueue`while `kevent()` is locked?

Let suppose a kqueue listening for files modifications: (Note: error management is removed for convenience in the example) #include #include #include #include #include #include…
Adrian Maire
  • 14,354
  • 9
  • 45
  • 85
0
votes
1 answer

Python Selector with FIFO running to infinite loop

I am trying to write some non-blocking FIFO code with kqueue on my BSD machine. Here's the small server code: server.py import os import selectors sel = selectors.KqueueSelector() TMP_PATH="/tmp/myfifo" def fifo_read(fd, mask): data =…
Rahul Bharadwaj
  • 2,555
  • 2
  • 18
  • 29
0
votes
2 answers

open(FileManager.default.fileSystemRepresentation(withPath: path), O_EVTONLY) returns -1

I am using SKQueue to monitor some folders in the mac filesystem. As per the documentation, I have added the directory paths to the queues but I noticed that while adding the path, the following line of code in SKQueue is returning -1 and hence it…
0
votes
1 answer

Kqueue/epoll (FreeBSD/Linux) with non-blocking socket: when can I free buffer memory after write/send/sendto?

I have non-blocking socket (TCP or UPD socket) with using kqueue/epoll (FreeBSD/Linux). When I want to transmit bytes to other side I can use write/send/sendto. Each of them take char* buffer to transmit, but I don`t understand when I have to free…
sribin
  • 1,736
  • 1
  • 13
  • 21
0
votes
0 answers

kqueue hangs with state 0x8 and size 4, using ZMQ

When I use ZMQ to receive messages over TCP on mac, I got the program using 100% of CPU after some hours. By using lsof, I found kqueue got into a wired state myprogram 56486 user 13u KQUEUE count=4,…
Musen
  • 1,244
  • 11
  • 23
1 2 3
8 9