Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 13 Aug 2022 21:19:16 +0200
From:      =?UTF-8?Q?Micha=C5=82_G=C3=B3rny?= <mgorny@moritz.systems>
To:        meator <meator.dev@gmail.com>, Gleb Popov <arrowd@freebsd.org>
Cc:        freebsd-hackers <freebsd-hackers@freebsd.org>
Subject:   Re: How to monitor a directory in FreeBSD?
Message-ID:  <0cb00216675d883162148e6dc1e0b90c4c8be5f2.camel@moritz.systems>
In-Reply-To: <d65728ec-935f-a1bc-a519-b6c82ca78ea8@gmail.com>
References:  <652f3c12-388c-04d0-ebeb-753b76b2b742@gmail.com> <CALH631m_q2VF8N4M%2ByCQVu4%2BeF6uue3TZ6KY%2BYzGc_zeWVa3bw@mail.gmail.com> <d65728ec-935f-a1bc-a519-b6c82ca78ea8@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 2022-08-13 at 21:09 +0200, meator wrote:
> On 8/13/22 17:35, Gleb Popov wrote:
> >=20
> > Yes, there is no native API to monitor directories. You can use=20
> > libinotify from ports, which replicates Linux inotify API and it does=
=20
> > have ability to monitor directories.
> >=20
>=20
> I would like to avoid extra dependencies. If I would like to do this,=20
> than I would probably choose FAM of Gamin. The Linux Programming=20
> Interface book references these two as a more cross platform=20
> alternatives to inotify. The program I'm working on should also work on=
=20
> Linux. I'm currently want to implement both inotify and kqueue and make=
=20
> the preprocessor pick the right one when compiling.
>=20
> But I didn't know inotify for BSD exists. This would mean that I=20
> wouldn't have to implement the directory monitoring twice. I'll take=20
> this into consideration. Thanks!

I'm afraid I'm going to be a bit of spoilsport but please bear in mind
that inotify -- at least on Linux -- is not 100% reliable (or at least
it wasn't the last time I've used it).  In general, it's a great
optimization but your program also needs to have fallback logic to
periodically check for changes that weren't reported.

--=20
Best regards,
Micha=C5=82 G=C3=B3rny




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?0cb00216675d883162148e6dc1e0b90c4c8be5f2.camel>