Live data from Hacker News

A quick review of file watchers

anarc.at

1–10 of 15 posts

Re: A quick review of file watchers

#5
This is very timely!

Linux still doesn't have a networked file watching protocol, does it? Like SGI fam, which gamin is based on. I understand SMB/CIFS supports this in the protocol, but Linux clients don't, and I don't remember if Samba does as a server.

inotify is still an ugly and error-prone interface but it does basically work.

What does the situation look like on other free OSes?

A common related requirement is to access a given version of a file, for example so that you know it's consistent with itself. Linux does support so-called "reflinks" for this... but ext4 doesn't. Sad trombone.

Re: A quick review of file watchers

#7
Fun fact, chokidar is a Sanskrit word meaning watchman.

It has an interesting root, it comes from the Proto Indo-European word for "four", because he must watch any enclosure of four walls. This ancient word is the source of the Latin "quartus" which comes into English as "quarter"

The PIE sense is echoed a little in phrases like "living quarters", "give no quarters" etc

Re: A quick review of file watchers

#8
post #6

`entr` is the homie

What have you used it for? From Anarcat's notes, it sounds like it isn't very generally applicable.

It's great for running unit tests on save, or hacking on python script and re-execute them when you need.

I often use something like this when iterating over stuff. This is a quick hack to list files I touched and differ from main.

    git diff main --name-only --relative | entr -r -c my-command
This of course needs to be killed and re-run if you want to pick up new files

Re: A quick review of file watchers

#9
It's a shame that fanotify[0] wasn't pointed out in this document also.

Only since seeing it used in 'zigs --watch' impl on Linux[1] (and the fact that I need to enable admin capabilities to run this in a container) has informed me of it's existence.

0. https://docs.kernel.org/admin-guide/filesystem-monitoring.ht...

1. https://ziggit.dev/t/initial-implementation-of-zig-build-wat...

Re: A quick review of file watchers

#10
post #8
post #6

Earlier quoted context omitted.

What have you used it for? From Anarcat's notes, it sounds like it isn't very generally applicable.

It's great for running unit tests on save, or hacking on python script and re-execute them when you need. I often use something like this when iterating over stuff. This is a quick hack to list files I touched and differ from main. git diff main --name-only --relative | entr -r -c my-command This of course needs to be killed and re-run if you want to pick up new files

That's a great tip!
Post reply on HN