Boost logo

Boost Users :

Subject: [Boost-users] Monitor OSX kqueue descriptor for events with ASIO
From: Blaine Walls (blainer.walls_at_[hidden])
Date: 2018-12-02 15:36:44

Hi all,

I'm using boost::asio on OS X. I'd like to watch for changes to a
particular regular file - per Apple's documentation, the preferred method
for this is with the kevent API. So I do the following:

1) Wrap a kqueue file descriptor (obtained via a call to kqueue()) in a
boost::asio::posix::stream_descriptor with
2) Call boost::asio::posix::stream_descriptor::async_wait() to be notified
of file events.

The problem appears to be that
boost::asio::posix::stream_descriptor::async_wait() uses ioctl() w/ FIONBIO
to put the file into non-blocking mode, which fails with "Inappropriate
ioctl for device".

A normal blocking call to wait() works just fine.

I realize that my problem is that the kqueue descriptor does not represent
a stream of bytes, so it's probably invalid to use stream_descriptor to
wrap it.

Does anyone have any ideas on how to work around this? I looked for a type
concept for a non-stream descriptor that I could implement, but I didn't
see anything obvious.

Thanks in advance for any advice,

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at